1
0
mirror of https://github.com/catseye/SixtyPical.git synced 2024-06-29 05:29:34 +00:00

Use words in demo.

This commit is contained in:
Cat's Eye Technologies 2014-04-02 21:37:23 +01:00
parent f5df4e5680
commit e8e9e00a19
4 changed files with 41 additions and 28 deletions

View File

@ -525,6 +525,8 @@ We cannot absolute access a vector.
| sty vbyte | sty vbyte
| cmp vbyte | cmp vbyte
| cmp #30 | cmp #30
| cmp <vword
| cmp >vword
| ldx vbyte | ldx vbyte
| cpx vbyte | cpx vbyte
| cpx #31 | cpx #31
@ -537,6 +539,8 @@ We cannot absolute access a vector.
| sta table, x | sta table, x
| sta table, y | sta table, y
| sta (vword), y | sta (vword), y
| sta <vword
| sta >vword
| dec vbyte | dec vbyte
| clc | clc
| cld | cld
@ -573,6 +577,8 @@ We cannot absolute access a vector.
= sty vbyte = sty vbyte
= cmp vbyte = cmp vbyte
= cmp #30 = cmp #30
= cmp vword
= cmp vword+1
= ldx vbyte = ldx vbyte
= cpx vbyte = cpx vbyte
= cpx #31 = cpx #31
@ -585,6 +591,8 @@ We cannot absolute access a vector.
= sta table, x = sta table, x
= sta table, y = sta table, y
= sta (vword), y = sta (vword), y
= sta vword
= sta vword+1
= dec vbyte = dec vbyte
= clc = clc
= cld = cld

View File

@ -14,24 +14,19 @@ assign byte table vic_bg 53281
assign vector cinv 788 assign vector cinv 788
reserve vector save_cinv reserve vector save_cinv
; TODO: this should be a word assign word position $fb
assign byte pos_lo $fb
assign byte pos_hi $fc
reserve byte value reserve byte value
reserve byte m_hi reserve word m
reserve byte m_lo reserve word n
reserve byte n_hi
reserve byte n_lo
routine main { routine main {
lda #5 lda #5
sta vic_border sta vic_border
lda #0 lda #0
sta vic_bg sta vic_bg
jsr reset_pos jsr reset_position
jsr clear_screen jsr clear_screen
sei { sei {
copy vector cinv to save_cinv copy vector cinv to save_cinv
@ -41,22 +36,22 @@ routine main {
repeat bcc { } repeat bcc { }
} }
routine reset_pos { routine reset_position {
lda #$00 lda #$00
sta pos_lo sta <position
lda #$04 lda #$04
sta pos_hi sta >position
} }
routine our_cinv { routine our_cinv {
lda value lda value
inc value inc value
ldy #0 ldy #0
sta (pos_lo), y sta (position), y
jsr increment_pos jsr increment_pos
jsr compare_pos jsr compare_pos
if beq { if beq {
jsr reset_pos jsr reset_position
} else { } else {
} }
jmp save_cinv jmp save_cinv
@ -64,32 +59,32 @@ routine our_cinv {
routine increment_pos { routine increment_pos {
clc clc
lda pos_lo lda <position
adc #1 adc #1
sta pos_lo sta <position
lda pos_hi lda >position
adc #0 adc #0
sta pos_hi sta >position
} }
routine compare_pos { routine compare_pos {
lda pos_lo lda <position
sta m_lo sta <m
lda pos_hi lda >position
sta m_hi sta >m
lda #$07 lda #$07
sta n_hi sta >n
lda #$e8 lda #$e8
sta n_lo sta <n
jsr compare_16_bit jsr compare_16_bit
} }
routine compare_16_bit { routine compare_16_bit {
lda m_hi lda >m
cmp n_hi cmp >n
if beq { if beq {
lda m_lo lda <m
cmp n_lo cmp <n
} else { } else {
} }
} }

View File

@ -52,6 +52,9 @@ emitInstr p r (COPY (NamedLocation st label) Y) = "ldy " ++ label
emitInstr p r (COPY (LowByteOf (NamedLocation st label)) A) = "lda " ++ label emitInstr p r (COPY (LowByteOf (NamedLocation st label)) A) = "lda " ++ label
emitInstr p r (COPY (HighByteOf (NamedLocation st label)) A) = "lda " ++ label ++ "+1" emitInstr p r (COPY (HighByteOf (NamedLocation st label)) A) = "lda " ++ label ++ "+1"
emitInstr p r (COPY A (LowByteOf (NamedLocation st label))) = "sta " ++ label
emitInstr p r (COPY A (HighByteOf (NamedLocation st label))) = "sta " ++ label ++ "+1"
emitInstr p r (COPY A X) = "tax" emitInstr p r (COPY A X) = "tax"
emitInstr p r (COPY A Y) = "tay" emitInstr p r (COPY A Y) = "tay"
emitInstr p r (COPY X A) = "txa" emitInstr p r (COPY X A) = "txa"
@ -74,6 +77,9 @@ emitInstr p r (CMP A (Immediate val)) = "cmp #" ++ (show val)
emitInstr p r (CMP X (Immediate val)) = "cpx #" ++ (show val) emitInstr p r (CMP X (Immediate val)) = "cpx #" ++ (show val)
emitInstr p r (CMP Y (Immediate val)) = "cpy #" ++ (show val) emitInstr p r (CMP Y (Immediate val)) = "cpy #" ++ (show val)
emitInstr p r (CMP A (LowByteOf (NamedLocation st label))) = "cmp " ++ label
emitInstr p r (CMP A (HighByteOf (NamedLocation st label))) = "cmp " ++ label ++ "+1"
emitInstr p r (ADD A (NamedLocation st label)) = "adc " ++ label emitInstr p r (ADD A (NamedLocation st label)) = "adc " ++ label
emitInstr p r (ADD A (Immediate val)) = "adc #" ++ (show val) emitInstr p r (ADD A (Immediate val)) = "adc #" ++ (show val)

View File

@ -272,6 +272,8 @@ cmp = do
addressing_mode gen addressing_mode gen
where where
gen (Immediately v) [] = CMP A (Immediate v) gen (Immediately v) [] = CMP A (Immediate v)
gen (LowBytely l) [] = CMP A (LowByteOf (NamedLocation Nothing l))
gen (HighBytely l) [] = CMP A (HighByteOf (NamedLocation Nothing l))
gen (Directly l) [] = CMP A (NamedLocation Nothing l) gen (Directly l) [] = CMP A (NamedLocation Nothing l)
cpx :: Parser Instruction cpx :: Parser Instruction
@ -365,6 +367,8 @@ sta = do
spaces spaces
addressing_mode gen addressing_mode gen
where where
gen (LowBytely l) [] = COPY A (LowByteOf (NamedLocation Nothing l))
gen (HighBytely l) [] = COPY A (HighByteOf (NamedLocation Nothing l))
gen (Directly l) [] = COPY A (NamedLocation Nothing l) gen (Directly l) [] = COPY A (NamedLocation Nothing l)
gen (Directly l) [reg] = COPY A (Indexed (NamedLocation Nothing l) reg) gen (Directly l) [reg] = COPY A (Indexed (NamedLocation Nothing l) reg)
gen (Indirectly l) [reg] = COPY A (IndirectIndexed (NamedLocation Nothing l) reg) gen (Indirectly l) [reg] = COPY A (IndirectIndexed (NamedLocation Nothing l) reg)