1
0
mirror of https://github.com/catseye/SixtyPical.git synced 2024-06-26 16:29:28 +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
| cmp vbyte
| cmp #30
| cmp <vword
| cmp >vword
| ldx vbyte
| cpx vbyte
| cpx #31
@ -537,6 +539,8 @@ We cannot absolute access a vector.
| sta table, x
| sta table, y
| sta (vword), y
| sta <vword
| sta >vword
| dec vbyte
| clc
| cld
@ -573,6 +577,8 @@ We cannot absolute access a vector.
= sty vbyte
= cmp vbyte
= cmp #30
= cmp vword
= cmp vword+1
= ldx vbyte
= cpx vbyte
= cpx #31
@ -585,6 +591,8 @@ We cannot absolute access a vector.
= sta table, x
= sta table, y
= sta (vword), y
= sta vword
= sta vword+1
= dec vbyte
= clc
= cld

View File

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

View File

@ -272,6 +272,8 @@ cmp = do
addressing_mode gen
where
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)
cpx :: Parser Instruction
@ -365,6 +367,8 @@ sta = do
spaces
addressing_mode gen
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) [reg] = COPY A (Indexed (NamedLocation Nothing l) reg)
gen (Indirectly l) [reg] = COPY A (IndirectIndexed (NamedLocation Nothing l) reg)