From 7ff872de23544415f67d0dbe594963c51110cbeb Mon Sep 17 00:00:00 2001 From: Craig Patterson Date: Fri, 28 Jul 2023 23:51:14 -0500 Subject: [PATCH] Run until ESC pressed Now runs until ESC key is pressed, rather than one generation per keypress. --- Debug/life.bin | Bin 848 -> 849 bytes Debug/life.hex | 18 +++++++++--------- Life.wsp | 8 ++++---- README.md | 4 ++-- Release/life.bin | Bin 848 -> 849 bytes Release/life.hex | 18 +++++++++--------- main.asm | 39 +++++++++++++++++---------------------- 7 files changed, 41 insertions(+), 46 deletions(-) diff --git a/Debug/life.bin b/Debug/life.bin index c548d5913936b5e5d80f9ee2767e548697229970..f0c9aaca18631bef6b44d2483ba6fa12c3a575f6 100644 GIT binary patch delta 285 zcmcb>c9Cs^Go!sXGXo_^5nP;MK{icOlXNK>3Kfbqr_OfOZQ{{=ulp z3e=`}W3n2Py~7Qli9jC2{F8R_(bw%5fY>_vx}qM$=~_UCC@TSpv-6o4PBJnuFxWA8 z-aq;G>D8lu70*sy%H*x|f{8&e)falU!~BuhWFcld E0A#;hFaQ7m delta 312 zcmcb}c7bh!Gh@9MGXocJe?o86f!TU5MHMpyG(T zbqr@&fld;d{F70W6=;Uy^~vf?_72y9#shf}%MjYFqpvIKLVTqKbd@s5X=mp#F`R^X z;N;(@SC9TxJTrM2lef}yCI&?bW(H2b*NGW#oj{O}fwRVlnVF$hU+CEm^GBkSg_-RD Ds?lNX diff --git a/Debug/life.hex b/Debug/life.hex index a074bc0..a5e1c8b 100644 --- a/Debug/life.hex +++ b/Debug/life.hex @@ -7,13 +7,13 @@ :40008000D15BC1F15BFDE1FDF95BFDE149C9014500CDEC005BDD0F005BDD235BDD235BDD23CDE300010100060FC55BE5CDD200795BD1C1B7C85BDD1F005BE55BD1CDE300CE :4000C000AF5B125BDD235BDD235BDD230C79B838D8C90E005B7EB7C8FE0DC8FE20C85B230C18F15B7EFE20C05B2318F75BE55BC55B210200005B395B775BC15BE1C95BDD2A :40010000E55BDD210200005BDD395BDD77005BDDE1C9000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007D -:400140000000214A0300010600005BDF213A0300CD950200CD900100CDB90100CDD60100CD1F0200CD7302003E0049CFB728EDFE1B20E921200300010000003E0049DF3E28 -:40018000175BD73E015BD73E015BD721000000C921000000224403002150030011510300AF7701361200EDB02187150011881500AF7701361200EDB0C921A003000639C5B3 -:4001C000064EE5CDE60200E13E013801AF772310F123C110EAC93E1F5BD73E005BD73E005BD7D5DD21A00300063950C5064E58DD7E00CD050200CD120200DD2310F0DD23D2 -:40020000C110E7D1C9F53E1F5BD77B5BD77A5BD7F1C94FFE013E2020023E8249D779C9DD21A0030021D715000639C5064EDD7EB0DD86B1DD86B2DD86FFDD8601DD864EDD57 -:40024000864FDD86501601FE03280C1600FE022006DD7E00E601577A7723DD2310CF23DD23C110C621D7150011A0030001361200EDB0C93E1F5BD73E005BD73E3B5BD721ED -:400280002D0300CD9502002A4403002322440300CD9E0200C9010000003E0049DFC9FDE5D5C5FD21CC020006060E06FD1700ED33043E2F3CA7ED5230FA19FE3020030D2037 -:4002C000045BD70E0110E4C1D1FDE1C9A086010010270000E8030000640000000A000000010000000000C501000000793CE60732E7020021180300094EEB6168ED42ED42AC -:40030000ED420E00097C320303007D2F12E6B837E21503003F17C1C95261786F6674140C0A0D46696E69736865640A0D0047656E65726174696F6E3A20001782183C42DBFA -:10034000DB423C1800000000000016031701000CFF +:400140000000214B0300010600005BDF213B0300CD960200CD9D0100CDC60100CD740200CDE30100CD2002003E0849CF5BDD7E1921480300BE28E5775BDD7E05FE1B20DC7E +:4001800021210300010000003E0049DF3E175BD73E015BD73E015BD721000000C921000000224503002151030011520300AF7701361200EDB02188150011891500AF77013A +:4001C000361200EDB0C921A103000639C5064EE5CDE70200E13E013801AF772310F123C110EAC9D5DD21A10300063950C5064E58DD7E00CD060200CD130200DD2310F0DDE9 +:4002000023C110E7D1C9F53E1F5BD77B5BD77A5BD7F1C94FFE013E2020023E8249D779C9DD21A1030021D815000639C5064EDD7EB0DD86B1DD86B2DD86FFDD8601DD864E0F +:40024000DD864FDD86501601FE03280C1600FE022006DD7E00E601577A7723DD2310CF23DD23C110C621D8150011A1030001361200EDB0C93E1F5BD73E005BD73E3B5BD72F +:40028000212E0300CD9602002A4503002322450300CD9F0200C9010000003E0049DFC9FDE5D5C5FD21CD020006060E06FD1700ED33043E2F3CA7ED5230FA19FE3020030D30 +:4002C00020045BD70E0110E4C1D1FDE1C9A086010010270000E8030000640000000A000000010000000000C501000000793CE60732E8020021190300094EEB6168ED42EDCC +:4003000042ED420E00097C320403007D2F12E6B837E21603003F17C1C95261786F6674140C0A0D46696E69736865640A0D0047656E65726174696F6E3A20001782183C4291 +:11034000DBDB423C1800000000000016031701000C23 :00000001FF diff --git a/Life.wsp b/Life.wsp index 3fe3459..1ebf4b9 100644 --- a/Life.wsp +++ b/Life.wsp @@ -30,9 +30,9 @@ ptn_Child1=ViewFrame-0 DocPathName=.\main.asm DocTemplateIndex=0 DocumentString=IDE.Document -IsActiveChildFrame=False +IsActiveChildFrame=True IsFrameVisible=True -WindowPlacement=MCAAAAAAAAAAAAAABAAAAAAAPPPPPPPPPPPPPPPPIPPPPPPPBOPPPPPPEDAAAAAAEDAAAAAAIEFAAAAAIBDAAAAA +WindowPlacement=MCAAAAAACAAAAAAADAAAAAAAPPPPPPPPPPPPPPPPIPPPPPPPBOPPPPPPEDAAAAAAEDAAAAAAIEFAAAAAIBDAAAAA [WorkState_v1_2.Frames.ChildFrames.Document-2] ptn_Child1=ViewFrame-0 @@ -74,7 +74,7 @@ ptn_Child1=ViewFrame-0 DocPathName=.\README.md DocTemplateIndex=0 DocumentString=IDE.Document -IsActiveChildFrame=True +IsActiveChildFrame=False IsFrameVisible=True -WindowPlacement=MCAAAAAACAAAAAAADAAAAAAAPPPPPPPPPPPPPPPPIPPPPPPPBOPPPPPPMJAAAAAAMJAAAAAAKIDAAAAADIDAAAAA +WindowPlacement=MCAAAAAAAAAAAAAABAAAAAAAPPPPPPPPPPPPPPPPIPPPPPPPBOPPPPPPMJAAAAAAMJAAAAAAKIDAAAAADIDAAAAA diff --git a/README.md b/README.md index e7efb31..5ec6084 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ Requires:
MOS 1.03
VDP 1.03 -Each generation is evaluated when you hit a key. Hitting Escape will exit. +Each generation is evaluated until you press Escape to exit. <<< Much more to come >>> @@ -68,7 +68,7 @@ TODO: * Make matrix 'infinite', full wrap-around in all directions * ~~Plot matrix properly, rather than clear screen, print row by row~~ * ~~Generation counter~~ -* Full run, with keyboard scan. Run until stopped, rather than one generation per keystroke +* ~~Full run, with keyboard scan. Run until stopped, rather than one generation per keystroke~~ * ~~Need a more 'random' random number generator~~ * User config of matrix start state diff --git a/Release/life.bin b/Release/life.bin index c548d5913936b5e5d80f9ee2767e548697229970..f0c9aaca18631bef6b44d2483ba6fa12c3a575f6 100644 GIT binary patch delta 285 zcmcb>c9Cs^Go!sXGXo_^5nP;MK{icOlXNK>3Kfbqr_OfOZQ{{=ulp z3e=`}W3n2Py~7Qli9jC2{F8R_(bw%5fY>_vx}qM$=~_UCC@TSpv-6o4PBJnuFxWA8 z-aq;G>D8lu70*sy%H*x|f{8&e)falU!~BuhWFcld E0A#;hFaQ7m delta 312 zcmcb}c7bh!Gh@9MGXocJe?o86f!TU5MHMpyG(T zbqr@&fld;d{F70W6=;Uy^~vf?_72y9#shf}%MjYFqpvIKLVTqKbd@s5X=mp#F`R^X z;N;(@SC9TxJTrM2lef}yCI&?bW(H2b*NGW#oj{O}fwRVlnVF$hU+CEm^GBkSg_-RD Ds?lNX diff --git a/Release/life.hex b/Release/life.hex index a074bc0..a5e1c8b 100644 --- a/Release/life.hex +++ b/Release/life.hex @@ -7,13 +7,13 @@ :40008000D15BC1F15BFDE1FDF95BFDE149C9014500CDEC005BDD0F005BDD235BDD235BDD23CDE300010100060FC55BE5CDD200795BD1C1B7C85BDD1F005BE55BD1CDE300CE :4000C000AF5B125BDD235BDD235BDD230C79B838D8C90E005B7EB7C8FE0DC8FE20C85B230C18F15B7EFE20C05B2318F75BE55BC55B210200005B395B775BC15BE1C95BDD2A :40010000E55BDD210200005BDD395BDD77005BDDE1C9000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007D -:400140000000214A0300010600005BDF213A0300CD950200CD900100CDB90100CDD60100CD1F0200CD7302003E0049CFB728EDFE1B20E921200300010000003E0049DF3E28 -:40018000175BD73E015BD73E015BD721000000C921000000224403002150030011510300AF7701361200EDB02187150011881500AF7701361200EDB0C921A003000639C5B3 -:4001C000064EE5CDE60200E13E013801AF772310F123C110EAC93E1F5BD73E005BD73E005BD7D5DD21A00300063950C5064E58DD7E00CD050200CD120200DD2310F0DD23D2 -:40020000C110E7D1C9F53E1F5BD77B5BD77A5BD7F1C94FFE013E2020023E8249D779C9DD21A0030021D715000639C5064EDD7EB0DD86B1DD86B2DD86FFDD8601DD864EDD57 -:40024000864FDD86501601FE03280C1600FE022006DD7E00E601577A7723DD2310CF23DD23C110C621D7150011A0030001361200EDB0C93E1F5BD73E005BD73E3B5BD721ED -:400280002D0300CD9502002A4403002322440300CD9E0200C9010000003E0049DFC9FDE5D5C5FD21CC020006060E06FD1700ED33043E2F3CA7ED5230FA19FE3020030D2037 -:4002C000045BD70E0110E4C1D1FDE1C9A086010010270000E8030000640000000A000000010000000000C501000000793CE60732E7020021180300094EEB6168ED42ED42AC -:40030000ED420E00097C320303007D2F12E6B837E21503003F17C1C95261786F6674140C0A0D46696E69736865640A0D0047656E65726174696F6E3A20001782183C42DBFA -:10034000DB423C1800000000000016031701000CFF +:400140000000214B0300010600005BDF213B0300CD960200CD9D0100CDC60100CD740200CDE30100CD2002003E0849CF5BDD7E1921480300BE28E5775BDD7E05FE1B20DC7E +:4001800021210300010000003E0049DF3E175BD73E015BD73E015BD721000000C921000000224503002151030011520300AF7701361200EDB02188150011891500AF77013A +:4001C000361200EDB0C921A103000639C5064EE5CDE70200E13E013801AF772310F123C110EAC9D5DD21A10300063950C5064E58DD7E00CD060200CD130200DD2310F0DDE9 +:4002000023C110E7D1C9F53E1F5BD77B5BD77A5BD7F1C94FFE013E2020023E8249D779C9DD21A1030021D815000639C5064EDD7EB0DD86B1DD86B2DD86FFDD8601DD864E0F +:40024000DD864FDD86501601FE03280C1600FE022006DD7E00E601577A7723DD2310CF23DD23C110C621D8150011A1030001361200EDB0C93E1F5BD73E005BD73E3B5BD72F +:40028000212E0300CD9602002A4503002322450300CD9F0200C9010000003E0049DFC9FDE5D5C5FD21CD020006060E06FD1700ED33043E2F3CA7ED5230FA19FE3020030D30 +:4002C00020045BD70E0110E4C1D1FDE1C9A086010010270000E8030000640000000A000000010000000000C501000000793CE60732E8020021190300094EEB6168ED42EDCC +:4003000042ED420E00097C320403007D2F12E6B837E21603003F17C1C95261786F6674140C0A0D46696E69736865640A0D0047656E65726174696F6E3A20001782183C4291 +:11034000DBDB423C1800000000000016031701000C23 :00000001FF diff --git a/main.asm b/main.asm index cb3f941..b7791af 100644 --- a/main.asm +++ b/main.asm @@ -3,16 +3,15 @@ ; Author: Craig Patterson ; Created: 06/30/2023 -; Conway's Game of Life for Amstrad CPC +; Conway's Game of Life for Agon Light ; ------------------------------------- -;(Fast Version) -; -; Amstrad CPC version written by Brian Chiha -; brian.chiha@gmail.com -- Mar 2021 ; ; Agon Light version written by Craig Patterson ; craiglp@gmail.com -- Jun 2023 ; +; Amstrad CPC version written by Brian Chiha +; brian.chiha@gmail.com -- Mar 2021 +; ; Game of Life is a cellular automation simulation. Each cell evolves based on the number ; of cells that surround it. The basic cell rules are: ; @@ -91,18 +90,21 @@ _main: start: CALL clear_cells CALL load_random ;Initialize cell data with random values - life: + CALL print_statusline CALL print_cells CALL conway ;Do Conway Rules on current cells - CALL print_statusline - - MOSCALL mos_getkey ;Loop until key pressed - OR A - JR Z, life ;No key pressed - CP ESC ;Escape pressed? - JR NZ,life ;Key pressed but not Escape + MOSCALL mos_sysvars ;get the sysvars location - consider saving IX for speed + ld.lil a,(IX+sysvar_vkeycount) ;check if any key has been pressed + ld hl,keycount + cp (hl) ;compare against keycount for change + jr z, life + ld (hl),a ;update keycount + ld.lil a,(IX+sysvar_keyascii) ;fetch character in queue + cp ESC ;is it Escape + jr nz, life + LD HL, s_LIFE_END ;Escape pressed, clean up and exit LD BC, 0 LD A, 0 @@ -118,7 +120,7 @@ life: LD HL, 0 ;Return, Error code = 0 RET - + clear_cells: LD HL, 0 LD (GENERATION), HL @@ -165,13 +167,6 @@ load_random: ;Loop through the current array and print cells print_cells: - LD A,31 ;Home text cursor - RST.LIL 10h - LD A,0 - RST.LIL 10h - LD A,0 - RST.LIL 10h - PUSH DE ;Save DE registers to use for plotting cells LD IX,CURRSTART @@ -197,7 +192,7 @@ print_cells: POP DE ;Restore DE registers RET ;Exit -;Print the cell at E,D (x,y) +;Move to the cell at E,D (x,y) plot_cell: PUSH AF