Skip to content

Commit

Permalink
Run until ESC pressed
Browse files Browse the repository at this point in the history
Now runs until ESC key is pressed, rather than one generation per keypress.
  • Loading branch information
craiglp committed Jul 29, 2023
1 parent bdcc480 commit 7ff872d
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 46 deletions.
Binary file modified Debug/life.bin
Binary file not shown.
18 changes: 9 additions & 9 deletions Debug/life.hex
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 4 additions & 4 deletions Life.wsp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Requires: <br>
MOS 1.03 <br>
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 >>>

Expand All @@ -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

Expand Down
Binary file modified Release/life.bin
Binary file not shown.
18 changes: 9 additions & 9 deletions Release/life.hex
Original file line number Diff line number Diff line change
Expand Up @@ -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
39 changes: 17 additions & 22 deletions main.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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:
;
Expand Down Expand Up @@ -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
Expand All @@ -118,7 +120,7 @@ life:

LD HL, 0 ;Return, Error code = 0
RET

clear_cells:
LD HL, 0
LD (GENERATION), HL
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down

0 comments on commit 7ff872d

Please sign in to comment.