Removed (pretty inconsistently used) tab chars from source code base.

This commit is contained in:
Oliver Schmidt
2013-05-09 13:56:54 +02:00
parent 44fd1082ae
commit 85885001b1
1773 changed files with 62864 additions and 62868 deletions

View File

@@ -4,7 +4,7 @@
; Screen size variables
;
.export screensize
.export screensize
.import SCREEN
screensize = SCREEN

View File

@@ -4,38 +4,38 @@
; Banking routines for the 610.
;
.export set_bank, sys_bank, restore_bank
.importzp ptr1, segsave
.export set_bank, sys_bank, restore_bank
.importzp ptr1, segsave
.include "cbm610.inc"
.include "cbm610.inc"
.code
.proc sys_bank
pha
lda IndReg
sta segsave
lda #$0F
sta IndReg
pla
rts
.proc sys_bank
pha
lda IndReg
sta segsave
lda #$0F
sta IndReg
pla
rts
.endproc
.proc set_bank
pha
lda IndReg
sta segsave
pla
sta IndReg
rts
.proc set_bank
pha
lda IndReg
sta segsave
pla
sta IndReg
rts
.endproc
.proc restore_bank
pha
lda segsave
sta IndReg
pla
rts
.proc restore_bank
pha
lda segsave
sta IndReg
pla
rts
.endproc

View File

@@ -5,66 +5,66 @@
; void reset_brk (void);
;
.export _set_brk, _reset_brk
.export _brk_a, _brk_x, _brk_y, _brk_sr, _brk_pc
.import _atexit, BRKVec
.export _set_brk, _reset_brk
.export _brk_a, _brk_x, _brk_y, _brk_sr, _brk_pc
.import _atexit, BRKVec
.include "cbm610.inc"
.include "cbm610.inc"
.bss
_brk_a: .res 1
_brk_x: .res 1
_brk_y: .res 1
_brk_sr: .res 1
_brk_pc: .res 2
_brk_01: .res 1
_brk_a: .res 1
_brk_x: .res 1
_brk_y: .res 1
_brk_sr: .res 1
_brk_pc: .res 2
_brk_01: .res 1
oldvec: .res 2 ; Old vector
oldvec: .res 2 ; Old vector
.data
uservec: jmp $FFFF ; Patched at runtime
uservec: jmp $FFFF ; Patched at runtime
.code
; Set the break vector
.proc _set_brk
.proc _set_brk
sta uservec+1
stx uservec+2 ; Set the user vector
sta uservec+1
stx uservec+2 ; Set the user vector
lda oldvec
ora oldvec+1 ; Did we save the vector already?
bne L1 ; Jump if we installed the handler already
lda oldvec
ora oldvec+1 ; Did we save the vector already?
bne L1 ; Jump if we installed the handler already
lda BRKVec
sta oldvec
lda BRKVec+1
sta oldvec+1 ; Save the old vector
lda BRKVec
sta oldvec
lda BRKVec+1
sta oldvec+1 ; Save the old vector
L1: lda #<brk_handler ; Set the break vector to our routine
ldx #>brk_handler
sta BRKVec
stx BRKVec+1
rts
L1: lda #<brk_handler ; Set the break vector to our routine
ldx #>brk_handler
sta BRKVec
stx BRKVec+1
rts
.endproc
; Reset the break vector
.proc _reset_brk
.proc _reset_brk
lda oldvec
ldx oldvec+1
beq @L9 ; Jump if vector not installed
sta BRKVec
stx BRKVec+1
lda #$00
sta oldvec ; Clear the old vector
stx oldvec+1
@L9: rts
lda oldvec
ldx oldvec+1
beq @L9 ; Jump if vector not installed
sta BRKVec
stx BRKVec+1
lda #$00
sta oldvec ; Clear the old vector
stx oldvec+1
@L9: rts
.endproc
@@ -72,42 +72,42 @@ L1: lda #<brk_handler ; Set the break vector to our routine
; Break handler, called if a break occurs
.proc brk_handler
.proc brk_handler
pla
sta _brk_01
pla
sta _brk_y
pla
sta _brk_x
pla
sta _brk_a
pla
and #$EF ; Clear break bit
sta _brk_sr
pla ; PC low
sec
sbc #2 ; Point to start of brk
sta _brk_pc
pla ; PC high
sbc #0
sta _brk_pc+1
sta _brk_01
pla
sta _brk_y
pla
sta _brk_x
pla
sta _brk_a
pla
and #$EF ; Clear break bit
sta _brk_sr
pla ; PC low
sec
sbc #2 ; Point to start of brk
sta _brk_pc
pla ; PC high
sbc #0
sta _brk_pc+1
jsr uservec ; Call the user's routine
jsr uservec ; Call the user's routine
lda _brk_01
lda _brk_01
sta IndReg
lda _brk_pc+1
pha
lda _brk_pc
pha
lda _brk_sr
pha
ldx _brk_x
ldy _brk_y
lda _brk_a
rti ; Jump back...
lda _brk_pc+1
pha
lda _brk_pc
pha
lda _brk_sr
pha
ldx _brk_x
ldy _brk_y
lda _brk_a
rti ; Jump back...
.endproc

View File

@@ -4,47 +4,47 @@
; char cgetc (void);
;
.export _cgetc
.import plot, write_crtc
.import cursor
.export _cgetc
.import plot, write_crtc
.import cursor
.import keyidx: zp, keybuf: zp, config: zp
_cgetc: lda keyidx ; Get number of characters
bne L2 ; Jump if there are already chars waiting
_cgetc: lda keyidx ; Get number of characters
bne L2 ; Jump if there are already chars waiting
; Switch on the cursor if needed
lda cursor
beq L1 ; Jump if no cursor
lda cursor
beq L1 ; Jump if no cursor
jsr plot ; Set the current cursor position
ldy #10
lda config ; Cursor format
jsr write_crtc ; Set the cursor formar
jsr plot ; Set the current cursor position
ldy #10
lda config ; Cursor format
jsr write_crtc ; Set the cursor formar
L1: lda keyidx
beq L1
L1: lda keyidx
beq L1
ldy #10
lda #$20 ; Cursor off
jsr write_crtc
ldy #10
lda #$20 ; Cursor off
jsr write_crtc
L2: ldx #$00 ; Get index
ldy keybuf ; Get first character in the buffer
sei
L3: lda keybuf+1,x ; Move up the remaining chars
sta keybuf,x
inx
cpx keyidx
bne L3
dec keyidx
cli
L2: ldx #$00 ; Get index
ldy keybuf ; Get first character in the buffer
sei
L3: lda keybuf+1,x ; Move up the remaining chars
sta keybuf,x
inx
cpx keyidx
bne L3
dec keyidx
cli
ldx #$00 ; High byte
tya ; First char from buffer
rts
ldx #$00 ; High byte
tya ; First char from buffer
rts

View File

@@ -4,38 +4,38 @@
; void clrscr (void);
;
.export _clrscr
.import plot
.export _clrscr
.import plot
.import CURS_X: zp, CURS_Y: zp, CharPtr: zp
.include "cbm610.inc"
.include "cbm610.inc"
.proc _clrscr
.proc _clrscr
lda #0
sta CURS_X
sta CURS_Y
jsr plot ; Set cursor to top left corner
lda #0
sta CURS_X
sta CURS_Y
jsr plot ; Set cursor to top left corner
lda IndReg
pha
lda #$0F
sta IndReg ; Switch to the system bank
lda IndReg
pha
lda #$0F
sta IndReg ; Switch to the system bank
ldx #8
ldy #$00
lda #$20 ; Screencode for blank
L1: sta (CharPtr),y
iny
bne L1
inc CharPtr+1
dex
bne L1
ldx #8
ldy #$00
lda #$20 ; Screencode for blank
L1: sta (CharPtr),y
iny
bne L1
inc CharPtr+1
dex
bne L1
pla
sta IndReg ; Restore old indirect segment
pla
sta IndReg ; Restore old indirect segment
jmp plot ; Set screen pointer again
jmp plot ; Set screen pointer again
.endproc

View File

@@ -6,15 +6,15 @@
; unsigned char __fastcall__ bordercolor (unsigned char color);
;
.export _textcolor, _bgcolor, _bordercolor
.import return0, return1
.export _textcolor, _bgcolor, _bordercolor
.import return0, return1
.include "cbm610.inc"
.include "cbm610.inc"
_textcolor = return1
_textcolor = return1
_bgcolor = return0
_bgcolor = return0
_bordercolor = return0
_bordercolor = return0

View File

@@ -5,51 +5,51 @@
; void cputc (char c);
;
.export _cputcxy, _cputc, cputdirect, putchar
.export newline, plot
.destructor setsyscursor
.export _cputcxy, _cputc, cputdirect, putchar
.export newline, plot
.destructor setsyscursor
.import _gotoxy
.import popa
.import PLOT
.import _gotoxy
.import popa
.import PLOT
.import ktmp: zp, crtc: zp, CURS_X: zp, CURS_Y: zp, RVS: zp
.import CharPtr: zp
.include "cbm610.inc"
.include "cbm610.inc"
_cputcxy:
pha ; Save C
jsr popa ; Get Y
jsr _gotoxy ; Set cursor, drop x
pla ; Restore C
pha ; Save C
jsr popa ; Get Y
jsr _gotoxy ; Set cursor, drop x
pla ; Restore C
; Plot a character - also used as internal function
_cputc: cmp #$0A ; CR?
bne L1
lda #0
sta CURS_X
beq plot ; Recalculate pointers
_cputc: cmp #$0A ; CR?
bne L1
lda #0
sta CURS_X
beq plot ; Recalculate pointers
L1: cmp #$0D ; LF?
beq newline ; Recalculate pointers
L1: cmp #$0D ; LF?
beq newline ; Recalculate pointers
; Printable char of some sort
cmp #' '
bcc cputdirect ; Other control char
tay
bmi L10
cmp #$60
bcc L2
and #$DF
bne cputdirect ; Branch always
L2: and #$3F
cmp #' '
bcc cputdirect ; Other control char
tay
bmi L10
cmp #$60
bcc L2
and #$DF
bne cputdirect ; Branch always
L2: and #$3F
cputdirect:
jsr putchar ; Write the character to the screen
jsr putchar ; Write the character to the screen
; Advance cursor position
@@ -63,87 +63,87 @@ L3: sty CURS_X
rts
newline:
clc
lda #XSIZE
adc CharPtr
sta CharPtr
bcc L4
inc CharPtr+1
L4: inc CURS_Y
rts
clc
lda #XSIZE
adc CharPtr
sta CharPtr
bcc L4
inc CharPtr+1
L4: inc CURS_Y
rts
; Handle character if high bit set
L10: and #$7F
cmp #$7E ; PI?
bne L11
lda #$5E ; Load screen code for PI
bne cputdirect
L11: ora #$40
bne cputdirect ; Branch always
L10: and #$7F
cmp #$7E ; PI?
bne L11
lda #$5E ; Load screen code for PI
bne cputdirect
L11: ora #$40
bne cputdirect ; Branch always
; Write one character to the screen without doing anything else, return X
; position in Y
putchar:
ldx IndReg
ldy #$0F
sty IndReg
ora RVS ; Set revers bit
ldy CURS_X
sta (CharPtr),y ; Set char
stx IndReg
rts
ldx IndReg
ldy #$0F
sty IndReg
ora RVS ; Set revers bit
ldy CURS_X
sta (CharPtr),y ; Set char
stx IndReg
rts
; Set cursor position, calculate RAM pointers
plot: ldx CURS_Y
lda LineLSBTab,x
sta CharPtr
lda LineMSBTab,x
sta CharPtr+1
lda LineLSBTab,x
sta CharPtr
lda LineMSBTab,x
sta CharPtr+1
lda IndReg
pha
lda #$0F
sta IndReg
lda IndReg
pha
lda #$0F
sta IndReg
ldy #$00
clc
sei
sta (crtc),y
lda CharPtr
adc CURS_X
iny
sta (crtc),y
dey
lda #$0E
sta (crtc),y
iny
lda (crtc),y
and #$F8
sta ktmp
lda CharPtr+1
adc #$00
and #$07
ora ktmp
sta (crtc),y
cli
ldy #$00
clc
sei
sta (crtc),y
lda CharPtr
adc CURS_X
iny
sta (crtc),y
dey
lda #$0E
sta (crtc),y
iny
lda (crtc),y
and #$F8
sta ktmp
lda CharPtr+1
adc #$00
and #$07
ora ktmp
sta (crtc),y
cli
pla
sta IndReg
rts
pla
sta IndReg
rts
; -------------------------------------------------------------------------
; Cleanup routine that sets the kernal cursor position to ours
.segment "PAGE2"
.segment "PAGE2"
setsyscursor:
ldy CURS_X
ldx CURS_Y
clc
jmp PLOT ; Set the new cursor
ldy CURS_X
ldx CURS_Y
clc
jmp PLOT ; Set the new cursor
; -------------------------------------------------------------------------
; Low bytes of the start address of the screen lines

View File

@@ -2,18 +2,18 @@
; Startup code for cc65 (CBM 600/700 version)
;
.export _exit, BRKVec
.export _exit, BRKVec
.export __STARTUP__ : absolute = 1 ; Mark as startup
.import callirq_y, initlib, donelib
.import push0, callmain
.import __BSS_RUN__, __BSS_SIZE__, __EXTZP_RUN__
.import __INTERRUPTOR_COUNT__
.import scnkey, UDTIM
.import callirq_y, initlib, donelib
.import push0, callmain
.import __BSS_RUN__, __BSS_SIZE__, __EXTZP_RUN__
.import __INTERRUPTOR_COUNT__
.import scnkey, UDTIM
.include "zeropage.inc"
.include "zeropage.inc"
.include "extzp.inc"
.include "cbm610.inc"
.include "cbm610.inc"
; ------------------------------------------------------------------------
@@ -36,8 +36,8 @@
; The machine program in the data lines is:
;
; sei
; lda #$01
; sta $00 <-- Switch to bank 1 after this command
; lda #$01
; sta $00 <-- Switch to bank 1 after this command
;
; Initialization is not only complex because of the jumping from one bank
; into another. but also because we want to save memory, and because of
@@ -47,11 +47,11 @@
.segment "EXEHDR"
.byte $03,$00,$11,$00,$0a,$00,$81,$20,$49,$b2,$30,$20,$a4,$20,$34,$00
.byte $19,$00,$14,$00,$87,$20,$4a,$00,$27,$00,$1e,$00,$97,$20,$32,$35
.byte $36,$aa,$49,$2c,$4a,$00,$2f,$00,$28,$00,$82,$20,$49,$00,$39,$00
.byte $32,$00,$9e,$20,$32,$35,$36,$00,$4f,$00,$3c,$00,$83,$20,$31,$32
.byte $30,$2c,$31,$36,$39,$2c,$31,$2c,$31,$33,$33,$2c,$30,$00,$00,$00
.byte $03,$00,$11,$00,$0a,$00,$81,$20,$49,$b2,$30,$20,$a4,$20,$34,$00
.byte $19,$00,$14,$00,$87,$20,$4a,$00,$27,$00,$1e,$00,$97,$20,$32,$35
.byte $36,$aa,$49,$2c,$4a,$00,$2f,$00,$28,$00,$82,$20,$49,$00,$39,$00
.byte $32,$00,$9e,$20,$32,$35,$36,$00,$4f,$00,$3c,$00,$83,$20,$31,$32
.byte $30,$2c,$31,$36,$39,$2c,$31,$2c,$31,$33,$33,$2c,$30,$00,$00,$00
;------------------------------------------------------------------------------
; A table that contains values that must be transfered from the system zero
@@ -182,15 +182,15 @@ expull: pla
.segment "STARTUP"
Back: sta ExecReg
Back: sta ExecReg
; We are at $100 now. The following snippet is a copy of the code that is poked
; in the system bank memory by the basic header program, it's only for
; documentation and not actually used here:
sei
lda #$01
sta ExecReg
sei
lda #$01
sta ExecReg
; This is the actual starting point of our code after switching banks for
; startup. Beware: The following code will get overwritten as soon as we
@@ -205,9 +205,9 @@ Back: sta ExecReg
sta ExecReg
rts
nop
.word nmi ; NMI vector
.word 0 ; Reset - not used
.word irq ; IRQ vector
.word nmi ; NMI vector
.word 0 ; Reset - not used
.word irq ; IRQ vector
.endproc
; Initializers for the extended zeropage. See extzp.s
@@ -215,23 +215,23 @@ Back: sta ExecReg
.proc extzp
.word $0100 ; sysp1
.word $0300 ; sysp3
.word $d800 ; crtc
.word $da00 ; sid
.word $db00 ; ipccia
.word $dc00 ; cia
.word $dd00 ; acia
.word $de00 ; tpi1
.word $df00 ; tpi2
.word $ea29 ; ktab1
.word $ea89 ; ktab2
.word $eae9 ; ktab3
.word $eb49 ; ktab4
.word $d800 ; crtc
.word $da00 ; sid
.word $db00 ; ipccia
.word $dc00 ; cia
.word $dd00 ; acia
.word $de00 ; tpi1
.word $df00 ; tpi2
.word $ea29 ; ktab1
.word $ea89 ; ktab2
.word $eae9 ; ktab3
.word $eb49 ; ktab4
.endproc
; Switch the indirect segment to the system bank
Origin: lda #$0F
sta IndReg
Origin: lda #$0F
sta IndReg
; Initialize the extended zeropage
@@ -247,8 +247,8 @@ L1: lda extzp,x
txa
ldy #$FF
sta (sysp1),y ; Save system stack point into $F:$1FF
ldx #$FE ; Leave $1FF untouched for cross bank calls
txs ; Set up our own stack
ldx #$FE ; Leave $1FF untouched for cross bank calls
txs ; Set up our own stack
; Copy stuff from the system zeropage to ours
@@ -266,18 +266,18 @@ L2: ldx ktmp
; Set the interrupt, NMI and other vectors
ldx #.sizeof(vectors)-1
L3: lda vectors,x
sta $10000 - .sizeof(vectors),x
dex
bpl L3
ldx #.sizeof(vectors)-1
L3: lda vectors,x
sta $10000 - .sizeof(vectors),x
dex
bpl L3
; Setup the C stack
lda #.lobyte(callbank15::entry)
sta sp
lda #.hibyte(callbank15::entry)
sta sp+1
lda #.lobyte(callbank15::entry)
sta sp
lda #.hibyte(callbank15::entry)
sta sp+1
; Setup the subroutine and jump vector table that redirects kernal calls to
; the system bank.
@@ -305,39 +305,39 @@ L3: lda vectors,x
; Set the indirect segment to bank we're executing in
lda ExecReg
sta IndReg
lda ExecReg
sta IndReg
; Zero the BSS segment. We will do that here instead calling the routine
; in the common library, since we have the memory anyway, and this way,
; it's reused later.
lda #<__BSS_RUN__
sta ptr1
lda #>__BSS_RUN__
sta ptr1+1
lda #0
tay
lda #<__BSS_RUN__
sta ptr1
lda #>__BSS_RUN__
sta ptr1+1
lda #0
tay
; Clear full pages
ldx #>__BSS_SIZE__
beq Z2
Z1: sta (ptr1),y
iny
bne Z1
inc ptr1+1 ; Next page
dex
bne Z1
ldx #>__BSS_SIZE__
beq Z2
Z1: sta (ptr1),y
iny
bne Z1
inc ptr1+1 ; Next page
dex
bne Z1
; Clear the remaining page
Z2: ldx #<__BSS_SIZE__
beq Z4
Z3: sta (ptr1),y
iny
dex
bne Z3
Z2: ldx #<__BSS_SIZE__
beq Z4
Z3: sta (ptr1),y
iny
dex
bne Z3
Z4: jmp Init
; ------------------------------------------------------------------------
@@ -350,22 +350,22 @@ Z4: jmp Init
Init: lda #.lobyte(__INTERRUPTOR_COUNT__*2)
sta irqcount
cli
cli
; Call module constructors.
jsr initlib
jsr initlib
; Push arguments and call main()
jsr callmain
jsr callmain
; Call module destructors. This is also the _exit entry and the default entry
; point for the break vector.
_exit: pha ; Save the return code
jsr donelib ; Run module destructors
lda #$00
_exit: pha ; Save the return code
jsr donelib ; Run module destructors
lda #$00
sta irqcount ; Disable custom irq handlers
; Address the system bank
@@ -391,9 +391,9 @@ _exit: pha ; Save the return code
; Place the program return code into ST
pla
ldy #$9C ; ST
sta (sysp0),y
pla
ldy #$9C ; ST
sta (sysp0),y
; Setup the welcome code at the stack bottom in the system bank.
@@ -406,9 +406,9 @@ _exit: pha ; Save the return code
iny
lda #$60 ; RTS opcode
sta (sysp1),y
lda IndReg
lda IndReg
sei
txs
txs
jmp Back
; -------------------------------------------------------------------------
@@ -416,7 +416,7 @@ _exit: pha ; Save the return code
; easier chaining, we do handle the IRQs in the execution bank (instead of
; passing them to the system bank).
; This is the mapping of the active irq register of the 6525 (tpi1):
; This is the mapping of the active irq register of the 6525 (tpi1):
;
; Bit 7 6 5 4 3 2 1 0
; | | | | ^ 50 Hz
@@ -434,10 +434,10 @@ irq: pha
pha
lda ExecReg
sta IndReg ; Be sure to address our segment
tsx
lda $105,x ; Get the flags from the stack
and #$10 ; Test break flag
bne dobrk
tsx
lda $105,x ; Get the flags from the stack
and #$10 ; Test break flag
bne dobrk
; It's an IRQ
@@ -445,40 +445,40 @@ irq: pha
; Call chained IRQ handlers
ldy irqcount
ldy irqcount
beq irqskip
jsr callirq_y ; Call the functions
jsr callirq_y ; Call the functions
; Done with chained IRQ handlers, check the TPI for IRQs and handle them
irqskip:lda #$0F
sta IndReg
ldy #TPI::AIR
lda (tpi1),y ; Interrupt Register 6525
beq noirq
irqskip:lda #$0F
sta IndReg
ldy #TPI::AIR
lda (tpi1),y ; Interrupt Register 6525
beq noirq
; 50/60Hz interrupt
cmp #%00000001 ; ticker irq?
bne irqend
jsr scnkey ; Poll the keyboard
jsr UDTIM ; Bump the time
cmp #%00000001 ; ticker irq?
bne irqend
jsr scnkey ; Poll the keyboard
jsr UDTIM ; Bump the time
; Done
irqend: ldy #TPI::AIR
sta (tpi1),y ; Clear interrupt
irqend: ldy #TPI::AIR
sta (tpi1),y ; Clear interrupt
noirq: pla
noirq: pla
sta IndReg
pla
tay
pla
tax
pla
nmi: rti
nmi: rti
dobrk: jmp (BRKVec)
dobrk: jmp (BRKVec)
; -------------------------------------------------------------------------
; Data area.

View File

@@ -4,54 +4,54 @@
; Write to the CRTC.
;
.export write_crtc, read_crtc
.importzp crtc, ktmp
.export write_crtc, read_crtc
.importzp crtc, ktmp
.include "cbm610.inc"
.include "cbm610.inc"
; Write a value to the CRTC. The index is in Y, the value in A
.proc write_crtc
sta ktmp
lda IndReg
pha
lda #$0F
sta IndReg
tya
ldy #$00
sei
sta (crtc),y
iny
lda ktmp
sta (crtc),y
cli
pla
sta IndReg
lda ktmp
rts
.proc write_crtc
sta ktmp
lda IndReg
pha
lda #$0F
sta IndReg
tya
ldy #$00
sei
sta (crtc),y
iny
lda ktmp
sta (crtc),y
cli
pla
sta IndReg
lda ktmp
rts
.endproc
.proc read_crtc
sty ktmp
lda IndReg
pha
lda #$0F
sta IndReg
lda ktmp
ldy #$00
sei
sta (crtc),y
iny
lda (crtc),y
cli
tay
pla
sta IndReg
tya
ldy ktmp
rts
.proc read_crtc
sty ktmp
lda IndReg
pha
lda #$0F
sta IndReg
lda ktmp
ldy #$00
sei
sta (crtc),y
iny
lda (crtc),y
cli
tay
pla
sta IndReg
tya
ldy ktmp
rts
.endproc

View File

@@ -2,6 +2,6 @@
; Oliver Schmidt, 2010-02-14
;
.include "extzp.inc"
.include "extzp.inc"
.exportzp devnum := DEVNUM
.exportzp devnum := DEVNUM

View File

@@ -5,9 +5,9 @@
; Ullrich von Bassewitz, 2002-12-09, 2003-12-20
;
.include "zeropage.inc"
.include "zeropage.inc"
.include "em-kernel.inc"
.include "em-kernel.inc"
.include "em-error.inc"
.include "cbm610.inc"
@@ -22,7 +22,7 @@
; Driver signature
.byte $65, $6d, $64 ; "emd"
.byte EMD_API_VERSION ; EM API version number
.byte EMD_API_VERSION ; EM API version number
; Jump table.
@@ -32,7 +32,7 @@
.word MAP
.word USE
.word COMMIT
.word COPYFROM
.word COPYFROM
.word COPYTO
; ------------------------------------------------------------------------
@@ -48,7 +48,7 @@ OFFS = 2
curpage: .res 1 ; Current page number
window: .res 256 ; Memory "window"
pagecount: .res 1 ; Number of available pages
pagecount: .res 1 ; Number of available pages
.code
@@ -61,14 +61,14 @@ pagecount: .res 1 ; Number of available pages
;
INSTALL:
lda #$FF
lda #$FF
sta curpage ; Invalidate the current page
sta pagecount ; Assume all memory available
sec
jsr $FF99 ; MEMTOP
cmp #RAMBANK ; Top of memory in bank 2?
cmp #RAMBANK ; Top of memory in bank 2?
bne @L1 ; No: We can use all the memory
txa
sub #OFFS
@@ -78,7 +78,7 @@ INSTALL:
@L1: lda #<EM_ERR_OK
ldx #>EM_ERR_OK
; rts ; Run into UNINSTALL instead
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
; UNINSTALL routine. Is called before the driver is removed from memory.
@@ -104,11 +104,11 @@ PAGECOUNT:
; by the driver.
;
MAP: sta curpage ; Remember the new page
MAP: sta curpage ; Remember the new page
sta ptr1+1
lda #OFFS
sta ptr1
sta ptr1+1
lda #OFFS
sta ptr1
; Transfer one page
@@ -143,7 +143,7 @@ USE: sta curpage ; Remember the page
; ------------------------------------------------------------------------
; COMMIT: Commit changes in the memory window to extended storage.
COMMIT: lda curpage ; Get the current page
COMMIT: lda curpage ; Get the current page
cmp #$FF
beq done ; Jump if no page mapped

View File

@@ -18,20 +18,20 @@
; initializer table
sysp1: .word $0000
sysp3: .word $0000
crtc: .word $0000
sid: .word $0000
ipccia: .word $0000
cia: .word $0000
acia: .word $0000
tpi1: .word $0000
tpi2: .word $0000
ktab1: .word $0000
ktab2: .word $0000
ktab3: .word $0000
ktab4: .word $0000
crtc: .word $0000
sid: .word $0000
ipccia: .word $0000
cia: .word $0000
acia: .word $0000
tpi1: .word $0000
tpi2: .word $0000
ktab1: .word $0000
ktab2: .word $0000
ktab3: .word $0000
ktab4: .word $0000
sysp0: .word $0000
time: .dword $0000
time: .dword $0000
segsave: .byte 0
ktmp: .byte 0
CURS_X: .byte 0

View File

@@ -5,16 +5,16 @@
; /* Return the video mode the machine is using */
;
.include "get_tv.inc"
.include "get_tv.inc"
;--------------------------------------------------------------------------
; _get_tv
.proc _get_tv
.proc _get_tv
lda #<TV::OTHER ; CRTC
ldx #>TV::OTHER
rts
lda #<TV::OTHER ; CRTC
ldx #>TV::OTHER
rts
.endproc

View File

@@ -2,8 +2,8 @@
; IRQ handling (CBM 600/700 version)
;
.export initirq, doneirq
.export initirq, doneirq
initirq:
doneirq:
rts
rts

View File

@@ -4,14 +4,14 @@
; unsigned char kbhit (void);
;
.export _kbhit
.export _kbhit
.import keyidx: zp
.proc _kbhit
ldx #0 ; High byte of return is always zero
lda keyidx ; Get number of characters
lda keyidx ; Get number of characters
beq L9
lda #1
L9: rts

View File

@@ -41,43 +41,43 @@
; replacements (usually short ones where the overhead of the cross bank call
; is not worth the trouble) are commented out.
CINT = $FF81
IOINIT = $FF84
RAMTAS = $FF87
RESTOR = $FF8A
VECTOR = $FF8D
SETMSG = $FF90
SECOND = $FF93
TKSA = $FF96
MEMTOP = $FF99
MEMBOT = $FF9C
SCNKEY = $FF9F
SETTMO = $FFA2
ACPTR = $FFA5
CIOUT = $FFA8
UNTLK = $FFAB
UNLSN = $FFAE
LISTEN = $FFB1
TALK = $FFB4
;READST = $FFB7
SETLFS = $FFBA
;SETNAM = $FFBD
;OPEN = $FFC0
;CLOSE = $FFC3
CHKIN = $FFC6
CKOUT = $FFC9
CLRCH = $FFCC
BASIN = $FFCF
BSOUT = $FFD2
LOAD = $FFD5
SAVE = $FFD8
;SETTIM = $FFDB
;RDTIM = $FFDE
STOP = $FFE1
GETIN = $FFE4
CLALL = $FFE7
;UDTIM = $FFEA
;SCREEN = $FFED
PLOT = $FFF0
;IOBASE = $FFF3
CINT = $FF81
IOINIT = $FF84
RAMTAS = $FF87
RESTOR = $FF8A
VECTOR = $FF8D
SETMSG = $FF90
SECOND = $FF93
TKSA = $FF96
MEMTOP = $FF99
MEMBOT = $FF9C
SCNKEY = $FF9F
SETTMO = $FFA2
ACPTR = $FFA5
CIOUT = $FFA8
UNTLK = $FFAB
UNLSN = $FFAE
LISTEN = $FFB1
TALK = $FFB4
;READST = $FFB7
SETLFS = $FFBA
;SETNAM = $FFBD
;OPEN = $FFC0
;CLOSE = $FFC3
CHKIN = $FFC6
CKOUT = $FFC9
CLRCH = $FFCC
BASIN = $FFCF
BSOUT = $FFD2
LOAD = $FFD5
SAVE = $FFD8
;SETTIM = $FFDB
;RDTIM = $FFDE
STOP = $FFE1
GETIN = $FFE4
CLALL = $FFE7
;UDTIM = $FFEA
;SCREEN = $FFED
PLOT = $FFF0
;IOBASE = $FFF3

View File

@@ -11,9 +11,9 @@
.proc IOBASE
ldx cia
ldy cia+1
rts
ldx cia
ldy cia+1
rts
.endproc

View File

@@ -10,12 +10,12 @@
.proc RDTIM
sei
lda time+0
ldx time+1
ldy time+2
cli
rts
sei
lda time+0
ldx time+1
ldy time+2
cli
rts
.endproc

View File

@@ -4,82 +4,82 @@
; Keyboard polling stuff for the 610.
;
.export scnkey
.importzp tpi2, ktab1, ktab2, ktab3, ktab4
.export scnkey
.importzp tpi2, ktab1, ktab2, ktab3, ktab4
.importzp keyidx, keybuf, keyscanbuf, keysave, modkey, norkey
.importzp graphmode, lastidx, rptdelay, rptcount
.include "cbm610.inc"
.include "cbm610.inc"
.proc scnkey
.proc scnkey
lda #$FF
sta modkey
sta norkey
lda #$00
sta keyscanbuf
ldy #TPI::PRB
sta (tpi2),y
ldy #TPI::PRA
sta (tpi2),y
lda #$00
sta keyscanbuf
ldy #TPI::PRB
sta (tpi2),y
ldy #TPI::PRA
sta (tpi2),y
jsr Poll
and #$3F
eor #$3F
bne L1
jmp NoKey
L1: lda #$FF
ldy #TPI::PRA
sta (tpi2),y
L1: lda #$FF
ldy #TPI::PRA
sta (tpi2),y
asl a
ldy #TPI::PRB
sta (tpi2),y
ldy #TPI::PRB
sta (tpi2),y
jsr Poll
pha
sta modkey
ora #$30
bne L3 ; Branch always
bne L3 ; Branch always
L2: jsr Poll
L3: ldx #$05
ldy #$00
L4: lsr a
L2: jsr Poll
L3: ldx #$05
ldy #$00
L4: lsr a
bcc L5
inc keyscanbuf
inc keyscanbuf
dex
bpl L4
sec
ldy #TPI::PRB
lda (tpi2),y
rol a
sta (tpi2),y
ldy #TPI::PRA
lda (tpi2),y
rol a
sta (tpi2),y
ldy #TPI::PRB
lda (tpi2),y
rol a
sta (tpi2),y
ldy #TPI::PRA
lda (tpi2),y
rol a
sta (tpi2),y
bcs L2
pla
bcc NoKey ; Branch always
bcc NoKey ; Branch always
L5: ldy keyscanbuf
sty norkey
L5: ldy keyscanbuf
sty norkey
pla
asl a
asl a
asl a
bcc L6
bmi L7
lda (ktab2),y ; Shifted normal key
lda (ktab2),y ; Shifted normal key
ldx graphmode
beq L8
lda (ktab3),y ; Shifted key in graph mode
lda (ktab3),y ; Shifted key in graph mode
bne L8
L6: lda (ktab4),y ; Key with ctrl pressed
bne L8
L7: lda (ktab1),y ; Normal key
L8: tax
cpx #$FF ; Valid key?
L6: lda (ktab4),y ; Key with ctrl pressed
bne L8
L7: lda (ktab1),y ; Normal key
L8: tax
cpx #$FF ; Valid key?
beq Done
cpy lastidx
beq Repeat
@@ -96,17 +96,17 @@ L8: tax
inx
bne PutKey
NoKey: ldy #$FF
Done: sty lastidx
End: lda #$7F
ldy #TPI::PRA
sta (tpi2),y
ldy #TPI::PRB
lda #$FF
sta (tpi2),y
NoKey: ldy #$FF
Done: sty lastidx
End: lda #$7F
ldy #TPI::PRA
sta (tpi2),y
ldy #TPI::PRB
lda #$FF
sta (tpi2),y
rts
Repeat: dec rptdelay
Repeat: dec rptdelay
bpl End
inc rptdelay
dec rptcount
@@ -115,7 +115,7 @@ Repeat: dec rptdelay
ldx keyidx
bne End
PutKey: sta keybuf,x
PutKey: sta keybuf,x
inx
stx keyidx
ldx #$03
@@ -130,14 +130,14 @@ PutKey: sta keybuf,x
.segment "PAGE2"
.proc Poll
ldy #TPI::PRC
L1: lda (tpi2),y
sta keysave
lda (tpi2),y
cmp keysave
bne L1
rts
.proc Poll
ldy #TPI::PRC
L1: lda (tpi2),y
sta keysave
lda (tpi2),y
cmp keysave
bne L1
rts
.endproc

View File

@@ -9,8 +9,8 @@
.proc SCREEN
ldx #80 ; Columns
ldy #25 ; Lines
rts
ldx #80 ; Columns
ldy #25 ; Lines
rts
.endproc

View File

@@ -29,9 +29,9 @@
iny
sta (sysp0),y
lda ExecReg ; Assume name is always in this segment
ldy #$92 ; FNAM_SEG
sta (sysp0),y
lda ExecReg ; Assume name is always in this segment
ldy #$92 ; FNAM_SEG
sta (sysp0),y
ldy #$9D ; FNAM_LEN
pla

View File

@@ -10,12 +10,12 @@
.proc SETTIM
sei
sta time+0
stx time+1
sty time+2
cli
rts
sei
sta time+0
stx time+1
sty time+2
cli
rts
.endproc

View File

@@ -8,16 +8,16 @@
.export UDTIM
.import time: zp
.proc UDTIM
.proc UDTIM
inc time
bne L9
inc time+1
bne L9
inc time+2
bne L9
inc time+3
L9: rts
inc time
bne L9
inc time+1
bne L9
inc time+2
bne L9
inc time+3
L9: rts
.endproc

View File

@@ -5,8 +5,8 @@
;
.constructor initmainargs, 24
.import __argc, __argv
.constructor initmainargs, 24
.import __argc, __argv
;---------------------------------------------------------------------------

View File

@@ -2,49 +2,49 @@
; Ullrich von Bassewitz, 14.09.2001
;
.export _peekbsys, _peekwsys
.importzp ptr1
.export _peekbsys, _peekwsys
.importzp ptr1
.include "cbm610.inc"
.include "cbm610.inc"
; ------------------------------------------------------------------------
; unsigned char __fastcall__ peekbsys (unsigned addr);
.proc _peekbsys
.proc _peekbsys
sta ptr1 ; Store argument pointer
stx ptr1+1
ldx IndReg
lda #$0F
sta IndReg
ldy #$00
lda (ptr1),y
stx IndReg
ldx #$00 ; Extend to word
rts
sta ptr1 ; Store argument pointer
stx ptr1+1
ldx IndReg
lda #$0F
sta IndReg
ldy #$00
lda (ptr1),y
stx IndReg
ldx #$00 ; Extend to word
rts
.endproc
; ------------------------------------------------------------------------
; unsigned __fastcall__ peekwsys (unsigned addr);
.proc _peekwsys
.proc _peekwsys
sta ptr1 ; Store argument pointer
stx ptr1+1
ldx IndReg
lda #$0F
sta IndReg
ldy #$00
lda (ptr1),y ; Get low byte
pha
iny
lda (ptr1),y ; Get high byte
stx IndReg
tax ; High byte -> X
pla ; Low byte -> A
rts
sta ptr1 ; Store argument pointer
stx ptr1+1
ldx IndReg
lda #$0F
sta IndReg
ldy #$00
lda (ptr1),y ; Get low byte
pha
iny
lda (ptr1),y ; Get high byte
stx IndReg
tax ; High byte -> X
pla ; Low byte -> A
rts
.endproc

View File

@@ -4,35 +4,35 @@
; void pokebsys (unsigned Addr, unsigned char Val);
; void pokewsys (unsigned Addr, unsigned Val);
.export _pokebsys, _pokewsys
.import popsreg
.importzp sreg, tmp1
.export _pokebsys, _pokewsys
.import popsreg
.importzp sreg, tmp1
.include "cbm610.inc"
.include "cbm610.inc"
_pokebsys:
jsr popsreg ; Get the address
ldx IndReg
ldy #$0F
sty IndReg ; Switch to the system bank
ldy #$00
sta (sreg),y
stx IndReg
rts
jsr popsreg ; Get the address
ldx IndReg
ldy #$0F
sty IndReg ; Switch to the system bank
ldy #$00
sta (sreg),y
stx IndReg
rts
_pokewsys:
stx tmp1 ; Save high byte
jsr popsreg ; Get the address
ldx IndReg
ldy #$0F
sty IndReg ; Switch to the system bank
ldy #$00
sta (sreg),y
iny
lda tmp1
sta (sreg),y
stx IndReg
rts
stx tmp1 ; Save high byte
jsr popsreg ; Get the address
ldx IndReg
ldy #$0F
sty IndReg ; Switch to the system bank
ldy #$00
sta (sreg),y
iny
lda tmp1
sta (sreg),y
stx IndReg
rts

View File

@@ -5,8 +5,8 @@
; /* Initialize the random number generator */
;
.export __randomize
.import _srand
.export __randomize
.import _srand
.importzp time
__randomize:

View File

@@ -4,7 +4,7 @@
; unsigned char revers (unsigned char onoff);
;
.export _revers
.export _revers
.import RVS: zp
@@ -13,18 +13,18 @@
.proc _revers
ldx #$00 ; Assume revers off
tay ; Test onoff
beq L1 ; Jump if off
ldx #$80 ; Load on value
ldy #$00 ; Assume old value is zero
L1: lda RVS ; Load old value
stx RVS ; Set new value
beq L2 ; Jump if old value zero
iny ; Make old value = 1
L2: ldx #$00 ; Load high byte of result
tya ; Load low byte, set CC
rts
ldx #$00 ; Assume revers off
tay ; Test onoff
beq L1 ; Jump if off
ldx #$80 ; Load on value
ldy #$00 ; Assume old value is zero
L1: lda RVS ; Load old value
stx RVS ; Set new value
beq L2 ; Jump if old value zero
iny ; Make old value = 1
L2: ldx #$00 ; Load high byte of result
tya ; Load low byte, set CC
rts
.endproc

View File

@@ -25,7 +25,7 @@
.include "../extzp.inc"
.include "ser-kernel.inc"
.include "ser-error.inc"
.include "cbm610.inc"
.include "cbm610.inc"
; ------------------------------------------------------------------------
@@ -48,7 +48,7 @@
.word PUT
.word STATUS
.word IOCTL
.word IRQ
.word IRQ
;----------------------------------------------------------------------------
;
@@ -56,19 +56,19 @@
;
.bss
RecvHead: .res 1 ; Head of receive buffer
RecvTail: .res 1 ; Tail of receive buffer
RecvFreeCnt: .res 1 ; Number of bytes in receive buffer
SendHead: .res 1 ; Head of send buffer
SendTail: .res 1 ; Tail of send buffer
SendFreeCnt: .res 1 ; Number of bytes in send buffer
RecvHead: .res 1 ; Head of receive buffer
RecvTail: .res 1 ; Tail of receive buffer
RecvFreeCnt: .res 1 ; Number of bytes in receive buffer
SendHead: .res 1 ; Head of send buffer
SendTail: .res 1 ; Tail of send buffer
SendFreeCnt: .res 1 ; Number of bytes in send buffer
Stopped: .res 1 ; Flow-stopped flag
RtsOff: .res 1 ;
Stopped: .res 1 ; Flow-stopped flag
RtsOff: .res 1 ;
; Send and receive buffers: 256 bytes each
RecvBuf: .res 256
SendBuf: .res 256
RecvBuf: .res 256
SendBuf: .res 256
.rodata
@@ -138,14 +138,14 @@ CLOSE:
; Deactivate DTR and disable 6551 interrupts
lda #%00001010
lda #%00001010
jsr write_cmd
; Done, return an error code
lda #<SER_ERR_OK
tax ; A is zero
rts
rts
;----------------------------------------------------------------------------
; PARAMS routine. A pointer to a ser_params structure is passed in ptr1.
@@ -155,22 +155,22 @@ OPEN:
; Check if the handshake setting is valid
ldy #SER_PARAMS::HANDSHAKE ; Handshake
ldy #SER_PARAMS::HANDSHAKE ; Handshake
lda (ptr1),y
cmp #SER_HS_HW ; This is all we support
bne InvParam
cmp #SER_HS_HW ; This is all we support
bne InvParam
; Initialize buffers
ldx #0
ldx #0
stx Stopped
stx RecvHead
stx RecvTail
stx SendHead
stx SendTail
stx RecvHead
stx RecvTail
stx SendHead
stx SendTail
dex ; X = 255
stx RecvFreeCnt
stx SendFreeCnt
stx RecvFreeCnt
stx SendFreeCnt
; Set the value for the control register, which contains stop bits, word
; length and the baud rate.
@@ -179,49 +179,49 @@ OPEN:
lda (ptr1),y ; Baudrate index
tay
lda BaudTable,y ; Get 6551 value
bmi InvBaud ; Branch if rate not supported
bmi InvBaud ; Branch if rate not supported
sta tmp1
ldy #SER_PARAMS::DATABITS ; Databits
ldy #SER_PARAMS::DATABITS ; Databits
lda (ptr1),y
tay
lda BitTable,y
ora tmp1
sta tmp1
ldy #SER_PARAMS::STOPBITS ; Stopbits
ldy #SER_PARAMS::STOPBITS ; Stopbits
lda (ptr1),y
tay
lda StopTable,y
ora tmp1
ora #%00010000 ; Receiver clock source = baudrate
ldy #ACIA::CTRL
ora #%00010000 ; Receiver clock source = baudrate
ldy #ACIA::CTRL
jsr write
; Set the value for the command register. We remember the base value in
; RtsOff, since we will have to manipulate ACIA_CMD often.
ldy #SER_PARAMS::PARITY ; Parity
ldy #SER_PARAMS::PARITY ; Parity
lda (ptr1),y
tay
lda ParityTable,y
ora #%00000001 ; DTR active
sta RtsOff
ora #%00001000 ; Enable receive interrupts
ora #%00000001 ; DTR active
sta RtsOff
ora #%00001000 ; Enable receive interrupts
jsr write_cmd
; Done
lda #<SER_ERR_OK
tax ; A is zero
rts
rts
; Invalid parameter
InvParam:
lda #<SER_ERR_INIT_FAILED
ldx #>SER_ERR_INIT_FAILED
rts
lda #<SER_ERR_INIT_FAILED
ldx #>SER_ERR_INIT_FAILED
rts
; Baud rate not available
@@ -236,43 +236,43 @@ InvBaud:
; return.
;
GET: ldx SendFreeCnt ; Send data if necessary
inx ; X == $FF?
beq @L1
lda #$00
jsr TryToSend
GET: ldx SendFreeCnt ; Send data if necessary
inx ; X == $FF?
beq @L1
lda #$00
jsr TryToSend
; Check for buffer empty
@L1: lda RecvFreeCnt
cmp #$ff
bne @L2
lda #<SER_ERR_NO_DATA
ldx #>SER_ERR_NO_DATA
rts
@L1: lda RecvFreeCnt
cmp #$ff
bne @L2
lda #<SER_ERR_NO_DATA
ldx #>SER_ERR_NO_DATA
rts
; Check for flow stopped & enough free: release flow control
@L2: ldx Stopped
beq @L3
cmp #63
bcc @L3
lda #$00
sta Stopped
lda RtsOff
ora #%00001000
@L2: ldx Stopped
beq @L3
cmp #63
bcc @L3
lda #$00
sta Stopped
lda RtsOff
ora #%00001000
jsr write_cmd
; Get byte from buffer
@L3: ldx RecvHead
lda RecvBuf,x
inc RecvHead
inc RecvFreeCnt
ldx #$00
sta (ptr1,x)
txa ; Return code = 0
rts
@L3: ldx RecvHead
lda RecvBuf,x
inc RecvHead
inc RecvFreeCnt
ldx #$00
sta (ptr1,x)
txa ; Return code = 0
rts
;----------------------------------------------------------------------------
; PUT: Output character in A.
@@ -283,30 +283,30 @@ PUT:
; Try to send
ldx SendFreeCnt
inx ; X = $ff?
beq @L2
pha
lda #$00
jsr TryToSend
pla
ldx SendFreeCnt
inx ; X = $ff?
beq @L2
pha
lda #$00
jsr TryToSend
pla
; Put byte into send buffer & send
@L2: ldx SendFreeCnt
bne @L3
lda #<SER_ERR_OVERFLOW ; X is already zero
rts
@L2: ldx SendFreeCnt
bne @L3
lda #<SER_ERR_OVERFLOW ; X is already zero
rts
@L3: ldx SendTail
sta SendBuf,x
inc SendTail
dec SendFreeCnt
lda #$ff
jsr TryToSend
lda #<SER_ERR_OK
tax
rts
@L3: ldx SendTail
sta SendBuf,x
inc SendTail
dec SendFreeCnt
lda #$ff
jsr TryToSend
lda #<SER_ERR_OK
tax
rts
;----------------------------------------------------------------------------
; STATUS: Return the status in the variable pointed to by ptr1.
@@ -317,11 +317,11 @@ STATUS: lda #$0F
sta IndReg
ldy #ACIA::STATUS
lda (acia),y
ldx #0
sta (ptr1,x)
ldx #0
sta (ptr1,x)
lda IndReg
sta ExecReg
txa ; SER_ERR_OK
txa ; SER_ERR_OK
rts
;----------------------------------------------------------------------------
@@ -345,25 +345,25 @@ IRQ: lda #$0F
sta IndReg ; Switch to the system bank
ldy #ACIA::STATUS
lda (acia),y ; Check ACIA status for receive interrupt
and #$08
beq @L9 ; Jump if no ACIA interrupt (carry still clear)
and #$08
beq @L9 ; Jump if no ACIA interrupt (carry still clear)
ldy #ACIA::DATA
lda (acia),y ; Get byte from ACIA
ldx RecvFreeCnt ; Check if we have free space left
beq @L1 ; Jump if no space in receive buffer
ldy RecvTail ; Load buffer pointer
sta RecvBuf,y ; Store received byte in buffer
inc RecvTail ; Increment buffer pointer
dec RecvFreeCnt ; Decrement free space counter
cpx #33 ; Check for buffer space low
bcs @L9 ; Assert flow control if buffer space low
lda (acia),y ; Get byte from ACIA
ldx RecvFreeCnt ; Check if we have free space left
beq @L1 ; Jump if no space in receive buffer
ldy RecvTail ; Load buffer pointer
sta RecvBuf,y ; Store received byte in buffer
inc RecvTail ; Increment buffer pointer
dec RecvFreeCnt ; Decrement free space counter
cpx #33 ; Check for buffer space low
bcs @L9 ; Assert flow control if buffer space low
; Assert flow control if buffer space too low
@L1: lda RtsOff
@L1: lda RtsOff
ldy #ACIA::CMD
sta (acia),y
sta Stopped
sta Stopped
sec ; Interrupt handled
; Done, switch back to the execution segment
@@ -377,26 +377,26 @@ IRQ: lda #$0F
.proc TryToSend
sta tmp1 ; Remember tryHard flag
sta tmp1 ; Remember tryHard flag
lda #$0F
sta IndReg ; Switch to the system bank
@L0: lda SendFreeCnt
cmp #$ff
beq @L3 ; Bail out
@L0: lda SendFreeCnt
cmp #$ff
beq @L3 ; Bail out
; Check for flow stopped
@L1: lda Stopped
bne @L3 ; Bail out
@L1: lda Stopped
bne @L3 ; Bail out
; Check that swiftlink is ready to send
@L2: ldy #ACIA::STATUS
@L2: ldy #ACIA::STATUS
lda (acia),y
and #$10
bne @L4
bit tmp1 ; Keep trying if must try hard
bmi @L0
and #$10
bne @L4
bit tmp1 ; Keep trying if must try hard
bmi @L0
; Switch back the bank and return
@@ -406,13 +406,13 @@ IRQ: lda #$0F
; Send byte and try again
@L4: ldx SendHead
lda SendBuf,x
@L4: ldx SendHead
lda SendBuf,x
ldy #ACIA::DATA
sta (acia),y
inc SendHead
inc SendFreeCnt
jmp @L0
sta (acia),y
inc SendHead
inc SendFreeCnt
jmp @L0
.endproc

View File

@@ -12,65 +12,65 @@
.include "time.inc"
.include "cbm610.inc"
.include "extzp.inc"
.include "extzp.inc"
.import sys_bank, restore_bank
.importzp tmp1, tmp2
.import sys_bank, restore_bank
.importzp tmp1, tmp2
;----------------------------------------------------------------------------
.code
.proc __systime
.proc __systime
; Switch to the system bank
jsr sys_bank
jsr sys_bank
; Read the clock
ldy #CIA::TODHR
lda (cia),y
bpl AM
and #%01111111
sed
clc
adc #$12
cld
AM: jsr BCD2dec
sta TM + tm::tm_hour
ldy #CIA::TODMIN
lda (cia),y
jsr BCD2dec
sta TM + tm::tm_min
ldy #CIA::TODSEC
lda (cia),y
jsr BCD2dec
sta TM + tm::tm_sec
ldy #CIA::TOD10
lda (cia),y ; Dummy read to unfreeze
ldy #CIA::TODHR
lda (cia),y
bpl AM
and #%01111111
sed
clc
adc #$12
cld
AM: jsr BCD2dec
sta TM + tm::tm_hour
ldy #CIA::TODMIN
lda (cia),y
jsr BCD2dec
sta TM + tm::tm_min
ldy #CIA::TODSEC
lda (cia),y
jsr BCD2dec
sta TM + tm::tm_sec
ldy #CIA::TOD10
lda (cia),y ; Dummy read to unfreeze
; Restore the bank
jsr restore_bank
jsr restore_bank
; Convert to a time
lda #<TM
ldx #>TM
jmp _mktime
lda #<TM
ldx #>TM
jmp _mktime
.endproc
;----------------------------------------------------------------------------
; dec = (((BCD>>4)*10) + (BCD&0xf))
.proc BCD2dec
.proc BCD2dec
tax
and #%00001111
sta tmp1
txa
tax
and #%00001111
sta tmp1
txa
and #%11110000 ; *16
lsr ; *8
sta tmp2
@@ -86,7 +86,7 @@ AM: jsr BCD2dec
; TM struct with date set to 1970-01-01
.data
TM: .word 0 ; tm_sec
TM: .word 0 ; tm_sec
.word 0 ; tm_min
.word 0 ; tm_hour
.word 1 ; tm_mday