git @ Cat's Eye Technologies SixtyPical / e8e9e00
Use words in demo. Cat's Eye Technologies 8 years ago
4 changed file(s) with 41 addition(s) and 28 deletion(s). Raw diff Collapse all Expand all
524524 | sty vbyte
525525 | cmp vbyte
526526 | cmp #30
527 | cmp <vword
528 | cmp >vword
527529 | ldx vbyte
528530 | cpx vbyte
529531 | cpx #31
536538 | sta table, x
537539 | sta table, y
538540 | sta (vword), y
541 | sta <vword
542 | sta >vword
539543 | dec vbyte
540544 | clc
541545 | cld
572576 = sty vbyte
573577 = cmp vbyte
574578 = cmp #30
579 = cmp vword
580 = cmp vword+1
575581 = ldx vbyte
576582 = cpx vbyte
577583 = cpx #31
584590 = sta table, x
585591 = sta table, y
586592 = sta (vword), y
593 = sta vword
594 = sta vword+1
587595 = dec vbyte
588596 = clc
589597 = cld
1313 assign vector cinv 788
1414 reserve vector save_cinv
1515
16 ; TODO: this should be a word
17
18 assign byte pos_lo $fb
19 assign byte pos_hi $fc
16 assign word position $fb
2017
2118 reserve byte value
2219
23 reserve byte m_hi
24 reserve byte m_lo
25 reserve byte n_hi
26 reserve byte n_lo
20 reserve word m
21 reserve word n
2722
2823 routine main {
2924 lda #5
3025 sta vic_border
3126 lda #0
3227 sta vic_bg
33 jsr reset_pos
28 jsr reset_position
3429 jsr clear_screen
3530 sei {
3631 copy vector cinv to save_cinv
4035 repeat bcc { }
4136 }
4237
43 routine reset_pos {
38 routine reset_position {
4439 lda #$00
45 sta pos_lo
40 sta <position
4641 lda #$04
47 sta pos_hi
42 sta >position
4843 }
4944
5045 routine our_cinv {
5146 lda value
5247 inc value
5348 ldy #0
54 sta (pos_lo), y
49 sta (position), y
5550 jsr increment_pos
5651 jsr compare_pos
5752 if beq {
58 jsr reset_pos
53 jsr reset_position
5954 } else {
6055 }
6156 jmp save_cinv
6358
6459 routine increment_pos {
6560 clc
66 lda pos_lo
61 lda <position
6762 adc #1
68 sta pos_lo
69 lda pos_hi
63 sta <position
64 lda >position
7065 adc #0
71 sta pos_hi
66 sta >position
7267 }
7368
7469 routine compare_pos {
75 lda pos_lo
76 sta m_lo
77 lda pos_hi
78 sta m_hi
70 lda <position
71 sta <m
72 lda >position
73 sta >m
7974 lda #$07
80 sta n_hi
75 sta >n
8176 lda #$e8
82 sta n_lo
77 sta <n
8378 jsr compare_16_bit
8479 }
8580
8681 routine compare_16_bit {
87 lda m_hi
88 cmp n_hi
82 lda >m
83 cmp >n
8984 if beq {
90 lda m_lo
91 cmp n_lo
85 lda <m
86 cmp <n
9287 } else {
9388 }
9489 }
5151 emitInstr p r (COPY (LowByteOf (NamedLocation st label)) A) = "lda " ++ label
5252 emitInstr p r (COPY (HighByteOf (NamedLocation st label)) A) = "lda " ++ label ++ "+1"
5353
54 emitInstr p r (COPY A (LowByteOf (NamedLocation st label))) = "sta " ++ label
55 emitInstr p r (COPY A (HighByteOf (NamedLocation st label))) = "sta " ++ label ++ "+1"
56
5457 emitInstr p r (COPY A X) = "tax"
5558 emitInstr p r (COPY A Y) = "tay"
5659 emitInstr p r (COPY X A) = "txa"
7275 emitInstr p r (CMP A (Immediate val)) = "cmp #" ++ (show val)
7376 emitInstr p r (CMP X (Immediate val)) = "cpx #" ++ (show val)
7477 emitInstr p r (CMP Y (Immediate val)) = "cpy #" ++ (show val)
78
79 emitInstr p r (CMP A (LowByteOf (NamedLocation st label))) = "cmp " ++ label
80 emitInstr p r (CMP A (HighByteOf (NamedLocation st label))) = "cmp " ++ label ++ "+1"
7581
7682 emitInstr p r (ADD A (NamedLocation st label)) = "adc " ++ label
7783 emitInstr p r (ADD A (Immediate val)) = "adc #" ++ (show val)
271271 addressing_mode gen
272272 where
273273 gen (Immediately v) [] = CMP A (Immediate v)
274 gen (LowBytely l) [] = CMP A (LowByteOf (NamedLocation Nothing l))
275 gen (HighBytely l) [] = CMP A (HighByteOf (NamedLocation Nothing l))
274276 gen (Directly l) [] = CMP A (NamedLocation Nothing l)
275277
276278 cpx :: Parser Instruction
364366 spaces
365367 addressing_mode gen
366368 where
369 gen (LowBytely l) [] = COPY A (LowByteOf (NamedLocation Nothing l))
370 gen (HighBytely l) [] = COPY A (HighByteOf (NamedLocation Nothing l))
367371 gen (Directly l) [] = COPY A (NamedLocation Nothing l)
368372 gen (Directly l) [reg] = COPY A (Indexed (NamedLocation Nothing l) reg)
369373 gen (Indirectly l) [reg] = COPY A (IndirectIndexed (NamedLocation Nothing l) reg)