mirror of
https://github.com/thelbane/ConwayII.git
synced 2024-06-19 18:29:30 +00:00
Fix tabs.
This commit is contained in:
parent
358b72e461
commit
7755f72501
|
@ -7,7 +7,7 @@
|
||||||
],
|
],
|
||||||
"settings":
|
"settings":
|
||||||
{
|
{
|
||||||
"tab_size": 16
|
"tab_size": 8
|
||||||
},
|
},
|
||||||
"build_systems":
|
"build_systems":
|
||||||
[
|
[
|
||||||
|
|
898
src/conway.asm
898
src/conway.asm
|
@ -3,519 +3,519 @@
|
||||||
; thelbane@gmail.com
|
; thelbane@gmail.com
|
||||||
; Created 03/14/2017
|
; Created 03/14/2017
|
||||||
|
|
||||||
processor 6502
|
processor 6502
|
||||||
incdir "include"
|
incdir "include"
|
||||||
include "apple2.asm"
|
include "apple2.asm"
|
||||||
include "macros.asm"
|
include "macros.asm"
|
||||||
|
|
||||||
; ------------------------------------
|
; ------------------------------------
|
||||||
; Build Options
|
; Build Options
|
||||||
; ------------------------------------
|
; ------------------------------------
|
||||||
|
|
||||||
USE_MAP equ 1
|
USE_MAP equ 1
|
||||||
USES_TXTPG0 equ 1
|
USES_TXTPG0 equ 1
|
||||||
USES_TXTPG1 equ 0
|
USES_TXTPG1 equ 0
|
||||||
NOISY equ 0
|
NOISY equ 0
|
||||||
|
|
||||||
; ------------------------------------
|
; ------------------------------------
|
||||||
; Constants
|
; Constants
|
||||||
; ------------------------------------
|
; ------------------------------------
|
||||||
|
|
||||||
textRow equ ZPA0
|
textRow equ ZPA0
|
||||||
textRowH equ ZPA1
|
textRowH equ ZPA1
|
||||||
|
|
||||||
mainData equ ZPC0
|
mainData equ ZPC0
|
||||||
mainDataH equ ZPC1
|
mainDataH equ ZPC1
|
||||||
|
|
||||||
altData equ ZPC2
|
altData equ ZPC2
|
||||||
altDataH equ ZPC3
|
altDataH equ ZPC3
|
||||||
|
|
||||||
currentPage equ ZPA2
|
currentPage equ ZPA2
|
||||||
temp equ ZPA3
|
temp equ ZPA3
|
||||||
|
|
||||||
fieldWidth equ 40
|
fieldWidth equ 40
|
||||||
fieldHeight equ 24
|
fieldHeight equ 24
|
||||||
|
|
||||||
dataWidth equ fieldWidth+2
|
dataWidth equ fieldWidth+2
|
||||||
dataHeight equ fieldHeight+2
|
dataHeight equ fieldHeight+2
|
||||||
|
|
||||||
charOn equ " " | %10000000
|
charOn equ " " | %10000000
|
||||||
charOff equ " " & %00111111
|
charOff equ " " & %00111111
|
||||||
noChange equ 0
|
noChange equ 0
|
||||||
|
|
||||||
topleft equ %10000000
|
topleft equ %10000000
|
||||||
top equ %01000000
|
top equ %01000000
|
||||||
topright equ %00100000
|
topright equ %00100000
|
||||||
left equ %00010000
|
left equ %00010000
|
||||||
right equ %00001000
|
right equ %00001000
|
||||||
bottomleft equ %00000100
|
bottomleft equ %00000100
|
||||||
bottom equ %00000010
|
bottom equ %00000010
|
||||||
bottomright equ %00000001
|
bottomright equ %00000001
|
||||||
|
|
||||||
n_topleft equ bottomright
|
n_topleft equ bottomright
|
||||||
n_top equ bottom
|
n_top equ bottom
|
||||||
n_topright equ bottomleft
|
n_topright equ bottomleft
|
||||||
n_left equ right
|
n_left equ right
|
||||||
n_right equ left
|
n_right equ left
|
||||||
n_bottomleft equ topright
|
n_bottomleft equ topright
|
||||||
n_bottom equ top
|
n_bottom equ top
|
||||||
n_bottomright equ topleft
|
n_bottomright equ topleft
|
||||||
|
|
||||||
n_offset equ dataWidth+1
|
n_offset equ dataWidth+1
|
||||||
|
|
||||||
y_topleft equ 0
|
y_topleft equ 0
|
||||||
y_top equ 1
|
y_top equ 1
|
||||||
y_topright equ 2
|
y_topright equ 2
|
||||||
y_left equ dataWidth
|
y_left equ dataWidth
|
||||||
y_right equ dataWidth+2
|
y_right equ dataWidth+2
|
||||||
y_bottomleft equ dataWidth*2
|
y_bottomleft equ dataWidth*2
|
||||||
y_bottom equ dataWidth*2+1
|
y_bottom equ dataWidth*2+1
|
||||||
y_bottomright equ dataWidth*2+2
|
y_bottomright equ dataWidth*2+2
|
||||||
|
|
||||||
y_copyfrom equ y_bottomright+1 ; Relative to current data pointer
|
y_copyfrom equ y_bottomright+1 ; Relative to current main pointer
|
||||||
y_copyto equ dataWidth+2 ; Relative to current neighbor pointer
|
y_copyto equ dataWidth+2 ; Relative to current alt pointer
|
||||||
|
|
||||||
; ------------------------------------
|
; ------------------------------------
|
||||||
; Entry Point
|
; Entry Point
|
||||||
; ------------------------------------
|
; ------------------------------------
|
||||||
seg program
|
seg program
|
||||||
org $C00
|
org $C00
|
||||||
|
|
||||||
start subroutine
|
start subroutine
|
||||||
jsr makeRules
|
jsr makeRules
|
||||||
lda #0
|
lda #0
|
||||||
sta currentPage
|
sta currentPage
|
||||||
jsr initScreen
|
jsr initScreen
|
||||||
jsr updateData
|
jsr updateData
|
||||||
.1 jsr iterate
|
.1 jsr iterate
|
||||||
jmp .1
|
jmp .1
|
||||||
LOG_REGION "start", start, 0
|
LOG_REGION "start", start, 0
|
||||||
|
|
||||||
flipPage subroutine
|
flipPage subroutine
|
||||||
lda #1
|
lda #1
|
||||||
eor currentPage
|
eor currentPage
|
||||||
sta currentPage
|
sta currentPage
|
||||||
rts
|
rts
|
||||||
|
|
||||||
iterate subroutine
|
iterate subroutine
|
||||||
|
|
||||||
mac TURN_ON
|
mac TURN_ON
|
||||||
ldy #y_{1}
|
ldy #y_{1}
|
||||||
lda (altData),y
|
lda (altData),y
|
||||||
ora #n_{1}
|
ora #n_{1}
|
||||||
sta (altData),y
|
sta (altData),y
|
||||||
endm
|
endm
|
||||||
|
|
||||||
jsr flipPage
|
jsr flipPage
|
||||||
jsr initUpdPtrs
|
jsr initUpdPtrs
|
||||||
lda #fieldHeight-1
|
lda #fieldHeight-1
|
||||||
sta .row
|
sta .row
|
||||||
.rowLoop jsr getRow
|
.rowLoop jsr getRow
|
||||||
lda #fieldWidth-1
|
lda #fieldWidth-1
|
||||||
sta .column
|
sta .column
|
||||||
.columnLoop ldy #0 ; get neighbor bit flags
|
.columnLoop ldy #0 ; get neighbor bit flags
|
||||||
lda (mainData),y ; at current data address
|
lda (mainData),y ; at current data address
|
||||||
tay
|
tay
|
||||||
lda conwayRules,y ; convert bit flags to cell state character (or 0 for do nothing)
|
lda conwayRules,y ; convert bit flags to cell state character (or 0 for do nothing)
|
||||||
beq .updateData ; rule says do nothing, so update the neighbor data (A = character)
|
beq .updateData ; rule says do nothing, so update the neighbor data (A = character)
|
||||||
ldy #0 ; .column
|
ldy #0 ; .column
|
||||||
.column equ .-1
|
.column equ .-1
|
||||||
sta (textRow),y ; set char based on rule
|
sta (textRow),y ; set char based on rule
|
||||||
.updateData ldy .column
|
.updateData ldy .column
|
||||||
lda (textRow),y
|
lda (textRow),y
|
||||||
cmp #charOn
|
cmp #charOn
|
||||||
bne .clearBit ; cell is disabled, so clear the topleft neighbor
|
bne .clearBit ; cell is disabled, so clear the topleft neighbor
|
||||||
if NOISY
|
if NOISY
|
||||||
bit CLICK
|
bit CLICK
|
||||||
endif
|
endif
|
||||||
ldy #y_topleft ; cell is enabled, so do the neighborly thing...
|
ldy #y_topleft ; cell is enabled, so do the neighborly thing...
|
||||||
lda #n_topleft
|
lda #n_topleft
|
||||||
sta (altData),y
|
sta (altData),y
|
||||||
TURN_ON topleft
|
TURN_ON topleft
|
||||||
if NOISY
|
if NOISY
|
||||||
bit CLICK
|
bit CLICK
|
||||||
endif
|
endif
|
||||||
TURN_ON top
|
TURN_ON top
|
||||||
TURN_ON topright
|
TURN_ON topright
|
||||||
TURN_ON left
|
TURN_ON left
|
||||||
TURN_ON right
|
TURN_ON right
|
||||||
TURN_ON bottomleft
|
TURN_ON bottomleft
|
||||||
TURN_ON bottom
|
TURN_ON bottom
|
||||||
TURN_ON bottomright
|
TURN_ON bottomright
|
||||||
jmp .continue
|
jmp .continue
|
||||||
.clearBit
|
.clearBit
|
||||||
ldy #y_topleft
|
ldy #y_topleft
|
||||||
lda #0
|
lda #0
|
||||||
sta (altData),y
|
sta (altData),y
|
||||||
|
|
||||||
.continue ldy #1
|
.continue ldy #1
|
||||||
lda #0
|
lda #0
|
||||||
sta (mainData),y
|
sta (mainData),y
|
||||||
sec
|
sec
|
||||||
lda mainData
|
lda mainData
|
||||||
sbc #1
|
sbc #1
|
||||||
sta mainData
|
sta mainData
|
||||||
lda mainDataH
|
lda mainDataH
|
||||||
sbc #0
|
sbc #0
|
||||||
sta mainDataH
|
sta mainDataH
|
||||||
sec
|
sec
|
||||||
lda altData
|
lda altData
|
||||||
sbc #1
|
sbc #1
|
||||||
sta altData
|
sta altData
|
||||||
lda altDataH
|
lda altDataH
|
||||||
sbc #0
|
sbc #0
|
||||||
sta altDataH
|
sta altDataH
|
||||||
.nextColumn dec .column
|
.nextColumn dec .column
|
||||||
bmi .nextRow
|
bmi .nextRow
|
||||||
jmp .columnLoop
|
jmp .columnLoop
|
||||||
.nextRow sec
|
.nextRow sec
|
||||||
lda mainData
|
lda mainData
|
||||||
sbc #2
|
sbc #2
|
||||||
sta mainData
|
sta mainData
|
||||||
lda mainDataH
|
lda mainDataH
|
||||||
sbc #0
|
sbc #0
|
||||||
sta mainDataH
|
sta mainDataH
|
||||||
sec
|
sec
|
||||||
lda altData
|
lda altData
|
||||||
sbc #2
|
sbc #2
|
||||||
sta altData
|
sta altData
|
||||||
lda altDataH
|
lda altDataH
|
||||||
sbc #0
|
sbc #0
|
||||||
sta altDataH
|
sta altDataH
|
||||||
dec .row
|
dec .row
|
||||||
lda #0 ; .row
|
lda #0 ; .row
|
||||||
.row equ .-1
|
.row equ .-1
|
||||||
bmi .end
|
bmi .end
|
||||||
jmp .rowLoop
|
jmp .rowLoop
|
||||||
.end rts
|
.end rts
|
||||||
|
|
||||||
updateData subroutine
|
updateData subroutine
|
||||||
jsr initUpdPtrs
|
jsr initUpdPtrs
|
||||||
lda #fieldHeight-1
|
lda #fieldHeight-1
|
||||||
sta .row
|
sta .row
|
||||||
.rowLoop jsr getRow
|
.rowLoop jsr getRow
|
||||||
lda #fieldWidth-1
|
lda #fieldWidth-1
|
||||||
sta .column
|
sta .column
|
||||||
.columnLoop ldy #0 ; .column
|
.columnLoop ldy #0 ; .column
|
||||||
.column equ .-1
|
.column equ .-1
|
||||||
lda (textRow),y
|
lda (textRow),y
|
||||||
cmp #charOff
|
cmp #charOff
|
||||||
beq .nextColumn
|
beq .nextColumn
|
||||||
TURN_ON topleft
|
TURN_ON topleft
|
||||||
TURN_ON top
|
TURN_ON top
|
||||||
TURN_ON topright
|
TURN_ON topright
|
||||||
TURN_ON left
|
TURN_ON left
|
||||||
TURN_ON right
|
TURN_ON right
|
||||||
TURN_ON bottomleft
|
TURN_ON bottomleft
|
||||||
TURN_ON bottom
|
TURN_ON bottom
|
||||||
TURN_ON bottomright
|
TURN_ON bottomright
|
||||||
.nextColumn sec
|
.nextColumn sec
|
||||||
lda altData
|
lda altData
|
||||||
sbc #1
|
sbc #1
|
||||||
sta altData
|
sta altData
|
||||||
lda altDataH
|
lda altDataH
|
||||||
sbc #0
|
sbc #0
|
||||||
sta altDataH
|
sta altDataH
|
||||||
dec .column
|
dec .column
|
||||||
bpl .columnLoop
|
bpl .columnLoop
|
||||||
.nextRow sec
|
.nextRow sec
|
||||||
lda altData
|
lda altData
|
||||||
sbc #2
|
sbc #2
|
||||||
sta altData
|
sta altData
|
||||||
lda altDataH
|
lda altDataH
|
||||||
sbc #0
|
sbc #0
|
||||||
sta altDataH
|
sta altDataH
|
||||||
dec .row
|
dec .row
|
||||||
lda #0 ; .row
|
lda #0 ; .row
|
||||||
.row equ .-1
|
.row equ .-1
|
||||||
bpl .rowLoop
|
bpl .rowLoop
|
||||||
rts
|
rts
|
||||||
|
|
||||||
initUpdPtrs subroutine ; Initializes the relevant data pointers
|
initUpdPtrs subroutine ; Initializes the relevant data pointers
|
||||||
lda currentPage
|
lda currentPage
|
||||||
bne .page1
|
bne .page1
|
||||||
.page0 lda <#datapg0_last
|
.page0 lda <#datapg0_last
|
||||||
sta mainData
|
sta mainData
|
||||||
lda >#datapg0_last
|
lda >#datapg0_last
|
||||||
sta mainDataH
|
sta mainDataH
|
||||||
lda <#datapg1_tln
|
lda <#datapg1_tln
|
||||||
sta altData
|
sta altData
|
||||||
lda >#datapg1_tln
|
lda >#datapg1_tln
|
||||||
sta altDataH
|
sta altDataH
|
||||||
jmp .continue
|
jmp .continue
|
||||||
.page1 lda <#datapg1_last
|
.page1 lda <#datapg1_last
|
||||||
sta mainData
|
sta mainData
|
||||||
lda >#datapg1_last
|
lda >#datapg1_last
|
||||||
sta mainDataH
|
sta mainDataH
|
||||||
lda <#datapg0_tln
|
lda <#datapg0_tln
|
||||||
sta altData
|
sta altData
|
||||||
lda >#datapg0_tln
|
lda >#datapg0_tln
|
||||||
sta altDataH
|
sta altDataH
|
||||||
.continue rts
|
.continue rts
|
||||||
|
|
||||||
initScreen subroutine
|
initScreen subroutine
|
||||||
lda <#initData
|
lda <#initData
|
||||||
sta mainData
|
sta mainData
|
||||||
lda >#initData
|
lda >#initData
|
||||||
sta mainDataH
|
sta mainDataH
|
||||||
lda #initDataLen-1 ; get data length
|
lda #initDataLen-1 ; get data length
|
||||||
sta .dataoffset ; save it
|
sta .dataoffset ; save it
|
||||||
lda #fieldHeight-1 ; load the field height
|
lda #fieldHeight-1 ; load the field height
|
||||||
sta .row ; save in row counter
|
sta .row ; save in row counter
|
||||||
.1 jsr getRow ; update textRow (A = row)
|
.1 jsr getRow ; update textRow (A = row)
|
||||||
lda #fieldWidth-1 ; load the field width (reset every new row)
|
lda #fieldWidth-1 ; load the field width (reset every new row)
|
||||||
sta .column ; save in column counter
|
sta .column ; save in column counter
|
||||||
ldy .dataoffset
|
ldy .dataoffset
|
||||||
lda (mainData),y ; get the current data byte
|
lda (mainData),y ; get the current data byte
|
||||||
sta .byte ; save it
|
sta .byte ; save it
|
||||||
lda #8 ; init the byte counter
|
lda #8 ; init the byte counter
|
||||||
sta .bit ; save in bit counter
|
sta .bit ; save in bit counter
|
||||||
.2 ldy .column
|
.2 ldy .column
|
||||||
lda #0
|
lda #0
|
||||||
.byte equ .-1
|
.byte equ .-1
|
||||||
lsr
|
lsr
|
||||||
sta .byte
|
sta .byte
|
||||||
bcs .turnOn
|
bcs .turnOn
|
||||||
.turnOff lda #charOff
|
.turnOff lda #charOff
|
||||||
bne .draw
|
bne .draw
|
||||||
.turnOn lda #charOn
|
.turnOn lda #charOn
|
||||||
.draw sta (textRow),y
|
.draw sta (textRow),y
|
||||||
dec .bit
|
dec .bit
|
||||||
bne .skipbit
|
bne .skipbit
|
||||||
lda #8 ; reset bit counter
|
lda #8 ; reset bit counter
|
||||||
sta .bit ; decrease data byte reference
|
sta .bit ; decrease data byte reference
|
||||||
sec
|
sec
|
||||||
dec .dataoffset
|
dec .dataoffset
|
||||||
ldy #0 ; .dataoffset
|
ldy #0 ; .dataoffset
|
||||||
.dataoffset equ .-1
|
.dataoffset equ .-1
|
||||||
lda (mainData),y
|
lda (mainData),y
|
||||||
sta .byte
|
sta .byte
|
||||||
.skipbit lda .column ; start to calculate init byte offset
|
.skipbit lda .column ; start to calculate init byte offset
|
||||||
dec .column
|
dec .column
|
||||||
ldy #0 ; .column
|
ldy #0 ; .column
|
||||||
.column equ .-1
|
.column equ .-1
|
||||||
bpl .2
|
bpl .2
|
||||||
dec .row
|
dec .row
|
||||||
lda #0 ; .row
|
lda #0 ; .row
|
||||||
.row equ .-1
|
.row equ .-1
|
||||||
bpl .1
|
bpl .1
|
||||||
rts
|
rts
|
||||||
.bit ds.b
|
.bit ds.b
|
||||||
|
|
||||||
; inputs:
|
; inputs:
|
||||||
; ?
|
; ?
|
||||||
; outputs:
|
; outputs:
|
||||||
; ?
|
; ?
|
||||||
setPoint subroutine
|
setPoint subroutine
|
||||||
jsr getRow
|
jsr getRow
|
||||||
lda #charOn
|
lda #charOn
|
||||||
sta (textRow),y
|
sta (textRow),y
|
||||||
rts
|
rts
|
||||||
|
|
||||||
; inputs:
|
; inputs:
|
||||||
; A = screen character code
|
; A = screen character code
|
||||||
; outputs:
|
; outputs:
|
||||||
; A = $FF, X = ?, Y = $FF
|
; A = $FF, X = ?, Y = $FF
|
||||||
fillScreen subroutine
|
fillScreen subroutine
|
||||||
sta .char
|
sta .char
|
||||||
lda #fieldHeight-1
|
lda #fieldHeight-1
|
||||||
sta .row
|
sta .row
|
||||||
.1 jsr getRow
|
.1 jsr getRow
|
||||||
ldy #fieldWidth-1
|
ldy #fieldWidth-1
|
||||||
.2 lda #0 ; .char
|
.2 lda #0 ; .char
|
||||||
.char equ .-1
|
.char equ .-1
|
||||||
sta (textRow),y
|
sta (textRow),y
|
||||||
dey
|
dey
|
||||||
bpl .2
|
bpl .2
|
||||||
dec .row
|
dec .row
|
||||||
lda #0 ; .row
|
lda #0 ; .row
|
||||||
.row equ .-1
|
.row equ .-1
|
||||||
bpl .1
|
bpl .1
|
||||||
rts
|
rts
|
||||||
LOG_REGION "fillScreen", fillScreen, 0
|
LOG_REGION "fillScreen", fillScreen, 0
|
||||||
; inputs:
|
; inputs:
|
||||||
; A = row
|
; A = row
|
||||||
; outputs:
|
; outputs:
|
||||||
; A = ?, X = A << 1
|
; A = ?, X = A << 1
|
||||||
getRow subroutine
|
getRow subroutine
|
||||||
asl
|
asl
|
||||||
tax
|
tax
|
||||||
lda tp0tbl,x
|
lda tp0tbl,x
|
||||||
sta textRow
|
sta textRow
|
||||||
lda tp0tbl+1,x
|
lda tp0tbl+1,x
|
||||||
sta textRowH
|
sta textRowH
|
||||||
rts
|
rts
|
||||||
LOG_REGION "getRow", getRow, 0
|
LOG_REGION "getRow", getRow, 0
|
||||||
|
|
||||||
makeRules subroutine ; Generate conway rules table
|
makeRules subroutine ; Generate conway rules table
|
||||||
lda #$ff
|
lda #$ff
|
||||||
sta .neighbors
|
sta .neighbors
|
||||||
.loop jsr getRule
|
.loop jsr getRule
|
||||||
ldx #0
|
ldx #0
|
||||||
.neighbors equ .-1
|
.neighbors equ .-1
|
||||||
sta conwayRules,x
|
sta conwayRules,x
|
||||||
dec .neighbors
|
dec .neighbors
|
||||||
lda .neighbors
|
lda .neighbors
|
||||||
bne .loop
|
bne .loop
|
||||||
lda #0
|
lda #0
|
||||||
sta conwayRules
|
sta conwayRules
|
||||||
rts
|
rts
|
||||||
|
|
||||||
getRule subroutine ; Returns #charOn, #charOff, or 0 (if no change)
|
getRule subroutine ; Returns #charOn, #charOff, or 0 (if no change)
|
||||||
jsr countBits ; Translate bit pattern to number of neighbors
|
jsr countBits ; Translate bit pattern to number of neighbors
|
||||||
cmp #2
|
cmp #2
|
||||||
bcc .off ; Fewer than 2 neighbors, dies of loneliness
|
bcc .off ; Fewer than 2 neighbors, dies of loneliness
|
||||||
cmp #3
|
cmp #3
|
||||||
beq .on ; Exactly 3 neighbors, reproduces
|
beq .on ; Exactly 3 neighbors, reproduces
|
||||||
bcs .off ; More than 3 neighbors, dies of overpopulation
|
bcs .off ; More than 3 neighbors, dies of overpopulation
|
||||||
lda #0 ; Else (exactly 2 neighbors), no change
|
lda #0 ; Else (exactly 2 neighbors), no change
|
||||||
rts
|
rts
|
||||||
.off lda #charOff
|
.off lda #charOff
|
||||||
rts
|
rts
|
||||||
.on lda #charOn
|
.on lda #charOn
|
||||||
rts
|
rts
|
||||||
|
|
||||||
countBits subroutine ; Compute Hamming Weight (number of enabled bits) in A
|
countBits subroutine ; Compute Hamming Weight (number of enabled bits) in A
|
||||||
.f1 equ %01010101 ; see: https://en.wikipedia.org/wiki/Hamming_weight
|
.f1 equ %01010101 ; see: https://en.wikipedia.org/wiki/Hamming_weight
|
||||||
.f2 equ %00110011 ; (Takes approx. 1/2 the time compared to lsr/adc loop.)
|
.f2 equ %00110011 ; (Takes approx. 1/2 the time compared to lsr/adc loop.)
|
||||||
.f3 equ %00001111
|
.f3 equ %00001111
|
||||||
tax
|
tax
|
||||||
and #.f1
|
and #.f1
|
||||||
sta .store1
|
sta .store1
|
||||||
txa
|
txa
|
||||||
lsr
|
lsr
|
||||||
and #.f1
|
and #.f1
|
||||||
clc
|
clc
|
||||||
adc #0 ; .store1
|
adc #0 ; .store1
|
||||||
.store1 equ .-1
|
.store1 equ .-1
|
||||||
tax
|
tax
|
||||||
and #.f2
|
and #.f2
|
||||||
sta .store2
|
sta .store2
|
||||||
txa
|
txa
|
||||||
lsr
|
lsr
|
||||||
lsr
|
lsr
|
||||||
and #.f2
|
and #.f2
|
||||||
clc
|
clc
|
||||||
adc #0 ; .store2
|
adc #0 ; .store2
|
||||||
.store2 equ .-1
|
.store2 equ .-1
|
||||||
tax
|
tax
|
||||||
and #.f3
|
and #.f3
|
||||||
sta .store3
|
sta .store3
|
||||||
txa
|
txa
|
||||||
lsr
|
lsr
|
||||||
lsr
|
lsr
|
||||||
lsr
|
lsr
|
||||||
lsr
|
lsr
|
||||||
and #.f3
|
and #.f3
|
||||||
clc
|
clc
|
||||||
adc #0 ; .store3
|
adc #0 ; .store3
|
||||||
.store3 equ .-1
|
.store3 equ .-1
|
||||||
rts
|
rts
|
||||||
|
|
||||||
; ------------------------------------
|
; ------------------------------------
|
||||||
; Utilities
|
; Utilities
|
||||||
; ------------------------------------
|
; ------------------------------------
|
||||||
|
|
||||||
include "utilities.asm"
|
include "utilities.asm"
|
||||||
|
|
||||||
; ------------------------------------
|
; ------------------------------------
|
||||||
; Tables
|
; Tables
|
||||||
; ------------------------------------
|
; ------------------------------------
|
||||||
if USES_TXTPG0
|
if USES_TXTPG0
|
||||||
tp0tbl subroutine
|
tp0tbl subroutine
|
||||||
.pg equ 1024
|
.pg equ 1024
|
||||||
.y set TXTPG0
|
.y set TXTPG0
|
||||||
repeat 24
|
repeat 24
|
||||||
dc.w .pg + (.y & %11111000) * 5 + ((.y & %00000111) << 7)
|
dc.w .pg + (.y & %11111000) * 5 + ((.y & %00000111) << 7)
|
||||||
.y set .y + 1
|
.y set .y + 1
|
||||||
repend
|
repend
|
||||||
LOG_REGION "tp0tbl", tp0tbl, 0
|
LOG_REGION "tp0tbl", tp0tbl, 0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if USES_TXTPG1
|
if USES_TXTPG1
|
||||||
align 256
|
align 256
|
||||||
tp1tbl subroutine
|
tp1tbl subroutine
|
||||||
.pg equ TXTPG1
|
.pg equ TXTPG1
|
||||||
.y set 0
|
.y set 0
|
||||||
repeat 50
|
repeat 50
|
||||||
dc.w .pg + (.y & %11111000) * 5 + ((.y & %00000111) << 7)
|
dc.w .pg + (.y & %11111000) * 5 + ((.y & %00000111) << 7)
|
||||||
.y set .y + 1
|
.y set .y + 1
|
||||||
repend
|
repend
|
||||||
LOG_REGION "tp1tbl", tp1tbl, 1
|
LOG_REGION "tp1tbl", tp1tbl, 1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if USE_MAP
|
if USE_MAP
|
||||||
initData dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
initData dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
||||||
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
||||||
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
||||||
dc.b %00000000,%00100000,%00000000,%00000000,%00000000
|
dc.b %00000000,%00100000,%00000000,%00000000,%00000000
|
||||||
dc.b %00000000,%00010000,%00000000,%00000000,%00010000
|
dc.b %00000000,%00010000,%00000000,%00000000,%00010000
|
||||||
dc.b %00000000,%01110000,%00000000,%00000000,%00100000
|
dc.b %00000000,%01110000,%00000000,%00000000,%00100000
|
||||||
dc.b %00000000,%00000000,%00000000,%00000000,%00111000
|
dc.b %00000000,%00000000,%00000000,%00000000,%00111000
|
||||||
dc.b %00000000,%00000000,%00000000,%00001000,%00000000
|
dc.b %00000000,%00000000,%00000000,%00001000,%00000000
|
||||||
dc.b %00000000,%00000000,%00000000,%00001010,%00000000
|
dc.b %00000000,%00000000,%00000000,%00001010,%00000000
|
||||||
dc.b %00001000,%00000000,%00000000,%00001100,%00000000
|
dc.b %00001000,%00000000,%00000000,%00001100,%00000000
|
||||||
dc.b %00000100,%00000000,%00000000,%00000000,%00000000
|
dc.b %00000100,%00000000,%00000000,%00000000,%00000000
|
||||||
dc.b %00011100,%00111000,%00000000,%00000000,%00000000
|
dc.b %00011100,%00111000,%00000000,%00000000,%00000000
|
||||||
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
||||||
dc.b %00000000,%00011100,%00111000,%00000000,%00000000
|
dc.b %00000000,%00011100,%00111000,%00000000,%00000000
|
||||||
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
||||||
dc.b %00000000,%00001110,%00000000,%00000000,%00001000
|
dc.b %00000000,%00001110,%00000000,%00000000,%00001000
|
||||||
dc.b %00000000,%00000000,%00000000,%00000000,%00010100
|
dc.b %00000000,%00000000,%00000000,%00000000,%00010100
|
||||||
dc.b %00000000,%00111000,%00000000,%00000000,%00010100
|
dc.b %00000000,%00111000,%00000000,%00000000,%00010100
|
||||||
dc.b %00000000,%01000100,%00001000,%00000000,%00010100
|
dc.b %00000000,%01000100,%00001000,%00000000,%00010100
|
||||||
dc.b %00000000,%00111000,%00010100,%00000000,%00001000
|
dc.b %00000000,%00111000,%00010100,%00000000,%00001000
|
||||||
dc.b %00000000,%00000000,%00010100,%00000000,%00000000
|
dc.b %00000000,%00000000,%00010100,%00000000,%00000000
|
||||||
dc.b %00000000,%00000000,%00001000,%00000000,%00000000
|
dc.b %00000000,%00000000,%00001000,%00000000,%00000000
|
||||||
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
||||||
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
||||||
else
|
else
|
||||||
initData dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
initData dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
||||||
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
||||||
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
||||||
dc.b %00000000,%01000000,%00000000,%00010000,%00000000
|
dc.b %00000000,%01000000,%00000000,%00010000,%00000000
|
||||||
dc.b %00000000,%00100000,%00000000,%00010000,%00011100
|
dc.b %00000000,%00100000,%00000000,%00010000,%00011100
|
||||||
dc.b %00000000,%11100000,%00000000,%00010000,%00000000
|
dc.b %00000000,%11100000,%00000000,%00010000,%00000000
|
||||||
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
||||||
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
||||||
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
||||||
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
||||||
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
||||||
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
||||||
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
||||||
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
||||||
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
||||||
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
||||||
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
||||||
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
||||||
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
||||||
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
||||||
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
||||||
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
||||||
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
||||||
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
dc.b %00000000,%00000000,%00000000,%00000000,%00000000
|
||||||
endif
|
endif
|
||||||
initDataLen equ .-initData
|
initDataLen equ .-initData
|
||||||
|
|
||||||
conwayRules ds.b 256
|
conwayRules ds.b 256
|
||||||
|
|
||||||
echo "--------"
|
echo "--------"
|
||||||
echo "CALL",[showDebug]d,": REM SHOW DEBUG"
|
echo "CALL",[showDebug]d,": REM SHOW DEBUG"
|
||||||
echo "CALL",[flipPage]d,": REM FLIP PAGE"
|
echo "CALL",[flipPage]d,": REM FLIP PAGE"
|
||||||
echo "CALL",[iterate]d,": REM ITERATE"
|
echo "CALL",[iterate]d,": REM ITERATE"
|
||||||
echo "POKE",[currentPage]d,", 0 : REM SET PAGE"
|
echo "POKE",[currentPage]d,", 0 : REM SET PAGE"
|
||||||
echo "--------"
|
echo "--------"
|
||||||
echo "Total length:", [.-start]d, "bytes"
|
echo "Total length:", [.-start]d, "bytes"
|
||||||
|
|
||||||
dataSeg equ .
|
dataSeg equ .
|
||||||
seg.u conwayData ; uninitialized data segment
|
seg.u conwayData ; uninitialized data segment
|
||||||
org dataSeg
|
org dataSeg
|
||||||
datapg0 ds.b dataWidth * dataHeight ; The start of data page 0 (padded)
|
datapg0 ds.b dataWidth * dataHeight ; The start of data page 0 (padded)
|
||||||
datapg0_last equ .-n_offset ; The last non-padding cell of data page 0 (topleft neighbor of last cell)
|
datapg0_last equ .-n_offset ; The last non-padding cell of data page 0 (topleft neighbor of last cell)
|
||||||
datapg0_tln equ datapg0_last - n_offset ; Top left neighbor of last non-padding cell of page 0
|
datapg0_tln equ datapg0_last - n_offset ; Top left neighbor of last non-padding cell of page 0
|
||||||
datapg0_end equ .-1
|
datapg0_end equ .-1
|
||||||
|
|
||||||
datapg1 ds.b dataWidth * dataHeight ; The start of data page 1 (padded)
|
datapg1 ds.b dataWidth * dataHeight ; The start of data page 1 (padded)
|
||||||
datapg1_last equ .-n_offset ; The last non-padding cell of data page 1 (topleft neighbor of last cell)
|
datapg1_last equ .-n_offset ; The last non-padding cell of data page 1 (topleft neighbor of last cell)
|
||||||
datapg1_tln equ datapg1_last - n_offset ; Top left neighbor of last non-padding cell of page 1
|
datapg1_tln equ datapg1_last - n_offset ; Top left neighbor of last non-padding cell of page 1
|
||||||
datapg1_end equ .-1
|
datapg1_end equ .-1
|
Loading…
Reference in New Issue
Block a user