Skip to content

Commit b13ea95

Browse files
committed
Better using labels and macros on cia
1 parent cd266ed commit b13ea95

1 file changed

Lines changed: 21 additions & 21 deletions

File tree

cia.asm

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,45 +13,50 @@ Entry: {
1313
clc
1414
ldx #5
1515
ldy #0
16-
jsr $fff0
16+
jsr c128lib.Kernal.PLOT
1717

1818
// Print string at current cursor position
1919
ldx #0
2020
!:
2121
lda Joy1, x
22-
jsr $FFD2
22+
jsr c128lib.Kernal.BSOUT
2323
inx
24-
cpx #$1B
24+
cpx #Joy1Length
2525
bne !-
2626

2727
// Set cursor on (0, 6)
2828
clc
2929
ldx #6
3030
ldy #0
31-
jsr $fff0
31+
jsr c128lib.Kernal.PLOT
3232

3333
// Print string at current cursor position
3434
ldx #0
3535
!:
3636
lda Joy2, x
37-
jsr $FFD2
37+
jsr c128lib.Kernal.BSOUT
3838
inx
39-
cpx #$1B
39+
cpx #Joy2Length
4040
bne !-
4141

4242
Loop:
4343
c128lib_GetFirePressedPort1()
44-
clc
45-
beq !Zero+
46-
adc #33
47-
jmp !Print+
48-
!Zero:
49-
adc #48
50-
51-
!Print:
52-
sta $04E3
44+
ConvertAccumulatorInZeroOrOneChar()
45+
sta $400 + c128lib_getTextOffset(27, 5)
5346

5447
c128lib_GetFirePressedPort2()
48+
ConvertAccumulatorInZeroOrOneChar()
49+
sta $400 + c128lib_getTextOffset(27, 6)
50+
51+
jmp Loop
52+
}
53+
54+
Joy1: .text "JOYSTICK 1 (0 IS PRESSED): "
55+
.label Joy1Length = $1B;
56+
Joy2: .text "JOYSTICK 2 (0 IS PRESSED): "
57+
.label Joy2Length = $1B;
58+
59+
.macro ConvertAccumulatorInZeroOrOneChar() {
5560
clc
5661
beq !Zero+
5762
adc #33
@@ -60,14 +65,9 @@ Entry: {
6065
adc #48
6166

6267
!Print:
63-
sta $050B
64-
65-
jmp Loop
6668
}
6769

68-
Joy1: .text "JOYSTICK 1 (0 IS PRESSED): "
69-
Joy2: .text "JOYSTICK 2 (0 IS PRESSED): "
70-
7170
#import "./common/lib/common-global.asm"
7271
#import "./common/lib/kernal.asm"
7372
#import "./chipset/lib/cia-global.asm"
73+
#import "./chipset/lib/vic2-global.asm"

0 commit comments

Comments
 (0)