Skip to content

Commit 40b5f74

Browse files
committed
Reorganize I/O tokens for shorter code.
1 parent cf7113a commit 40b5f74

File tree

8 files changed

+97
-212
lines changed

8 files changed

+97
-212
lines changed

Makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ COMMON_AS_SRC=\
114114
src/interp/bitexor.asm\
115115
src/interp/bitor.asm\
116116
src/interp/cdata.asm\
117-
src/interp/close.asm\
118117
src/interp/chr.asm\
119118
src/interp/cmpstr.asm\
120119
src/interp/comp0.asm\
@@ -125,7 +124,6 @@ COMMON_AS_SRC=\
125124
src/interp/div.asm\
126125
src/interp/dpeek.asm\
127126
src/interp/dpoke.asm\
128-
src/interp/drawto.asm\
129127
src/interp/for.asm\
130128
src/interp/for_exit.asm\
131129
src/interp/free.asm\
@@ -134,7 +132,6 @@ COMMON_AS_SRC=\
134132
src/interp/inc.asm\
135133
src/interp/input.asm\
136134
src/interp/iochn.asm\
137-
src/interp/ioget.asm\
138135
src/interp/jump.asm\
139136
src/interp/land.asm\
140137
src/interp/lnot.asm\

src/interp/bgetput.asm

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
; Block-GET and Block-PUT
2828
; -----------------------
2929

30-
.import CIOV_CMD_POP2, stack_l, stack_h
30+
.import CIOV_CMD_POP2, stack_l, stack_h, IOCHN_16
3131

3232
.include "atari.inc"
3333

@@ -40,33 +40,26 @@
4040
.proc EXE_BGET
4141
sec
4242

43-
php
44-
45-
pha
43+
pha ; Length
4644
txa
4745
pha
4846

49-
lda stack_l+1,y
50-
asl
51-
asl
52-
asl
53-
asl
54-
tax
47+
lda stack_h, y ; Address H
48+
pha
5549

56-
pla
57-
sta ICBLH, x
58-
pla
59-
sta ICBLL, x ; Length
50+
lda stack_l, y ; Address L
51+
pha
6052

61-
lda stack_l, y
62-
sta ICBAL, x ; Address
63-
lda stack_h, y
53+
lda stack_l+1,y ; I/O channel
6454

65-
plp
66-
ldy #GETCHR
55+
ldy #GETCHR ; Command
6756
bcs bget
6857
ldy #PUTCHR
6958
bget:
59+
60+
jsr IOCHN_16
61+
62+
pla
7063
jmp CIOV_CMD_POP2 ; Note: A is never 0
7164
.endproc
7265

src/interp/close.asm

Lines changed: 0 additions & 57 deletions
This file was deleted.

src/interp/drawto.asm

Lines changed: 0 additions & 47 deletions
This file was deleted.

src/interp/graphics.asm

Lines changed: 57 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,32 +24,78 @@
2424
; linked into a combine executable.)
2525

2626

27-
; Graphics command
28-
; ----------------
27+
; Graphics commands and I/O:
28+
; GRAPHICS; DRAWTO (and FILLTO), GET and CLOSE
29+
; --------------------------------------------
2930

30-
.import CIOV_CMD_AH
31+
.export CIOV_CMD_A, CIOV_CMD, CIOV_IOERR
32+
.import IOCHN_16
33+
.importzp COLOR, IOCHN, IOERROR, next_instruction
3134

3235
.include "atari.inc"
3336

3437
.segment "RUNTIME"
3538

36-
.proc EXE_GRAPHICS ; OPEN #6,12,0,
39+
.proc EXE_GRAPHICS ; OPEN #6,12,MODE,"S:"
3740
ldx #$60
38-
tay
41+
sta ICAX2, x; Store BASIC mode into AUX2
3942
and #$F0
40-
eor #$1C ; Get AUX1 from BASIC mode
43+
eor #$1C ; and flags into AUX1
4144
sta ICAX1, x
42-
tya ; And AUX2
43-
sta ICAX2, x
44-
lda #<device_s
45-
sta ICBAL, x
45+
pha
46+
pha
4647
lda #>device_s
48+
pha
49+
lda #<device_s
4750
ldy #OPEN
48-
jmp CIOV_CMD_AH
51+
.endproc
52+
53+
CIOV_CMD_A:
54+
sta ICBAL, x ; Address
55+
pla
56+
sta ICBAH, x
57+
pla ; Length
58+
CIOV_CMD_L:
59+
sta ICBLH, x
60+
pla
61+
sta ICBLL, x
62+
tya ; Command
63+
; Calls CIO with given command, stores I/O error and pops stack
64+
CIOV_CMD:
65+
sta ICCOM, x
66+
; Calls CIOV, stores I/O error and pops stack
67+
jsr CIOV
68+
ldx #0 ; Needed for TOK_GET
69+
CIOV_IOERR:
70+
sty IOERROR
71+
jmp next_instruction
72+
4973
device_s: .byte "S:", $9B
74+
75+
EXE_CLOSE:
76+
jsr IOCHN_16
77+
lda #CLOSE
78+
bne CIOV_CMD
79+
80+
.proc EXE_DRAWTO ; CIO COMMAND in A
81+
ldx COLOR
82+
stx ATACHR
83+
ldx #$60 ; IOCB #6
84+
bne CIOV_CMD
85+
.endproc
86+
87+
.proc EXE_GET
88+
ldx IOCHN
89+
lda #0 ; Length = 0
90+
pha
91+
ldy #GETCHR
92+
bne CIOV_CMD_L
5093
.endproc
5194

5295
.include "../deftok.inc"
96+
deftoken "CLOSE"
97+
deftoken "DRAWTO"
98+
deftoken "GET"
5399
deftoken "GRAPHICS"
54100

55101
; vi:syntax=asm_ca65

src/interp/iochn.asm

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,24 @@
2727
; Set I/O channel to A
2828
; --------------------
2929

30+
.export IOCHN_16
3031
.importzp IOCHN, next_instruction
3132

3233
.segment "RUNTIME"
3334

3435
.proc EXE_IOCHN
36+
jsr IOCHN_16
37+
stx IOCHN
38+
jmp next_instruction
39+
.endproc
40+
41+
.proc IOCHN_16
3542
asl
3643
asl
3744
asl
3845
asl
39-
sta IOCHN
40-
jmp next_instruction
46+
tax
47+
rts
4148
.endproc
4249

4350
.include "../deftok.inc"

src/interp/ioget.asm

Lines changed: 0 additions & 52 deletions
This file was deleted.

0 commit comments

Comments
 (0)