Removed (pretty inconsistently used) tab chars from source code base.
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
; Screen size variables
|
||||
;
|
||||
|
||||
.export screensize
|
||||
.export screensize
|
||||
.import SCREEN
|
||||
|
||||
screensize = SCREEN
|
||||
|
||||
@@ -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 "cbm510.inc"
|
||||
.include "cbm510.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
|
||||
|
||||
|
||||
|
||||
@@ -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 "cbm510.inc"
|
||||
.include "cbm510.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
|
||||
|
||||
|
||||
@@ -4,93 +4,93 @@
|
||||
; char cgetc (void);
|
||||
;
|
||||
|
||||
.export _cgetc
|
||||
.condes k_blncur, 2
|
||||
.import cursor
|
||||
.export _cgetc
|
||||
.condes k_blncur, 2
|
||||
.import cursor
|
||||
|
||||
.include "cbm510.inc"
|
||||
.include "cbm510.inc"
|
||||
.include "extzp.inc"
|
||||
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
|
||||
.proc _cgetc
|
||||
.proc _cgetc
|
||||
|
||||
lda keyidx ; Characters waiting?
|
||||
bne L3 ; Jump if so
|
||||
lda keyidx ; Characters waiting?
|
||||
bne L3 ; Jump if so
|
||||
|
||||
; Switch on the cursor if needed
|
||||
|
||||
lda CURS_FLAG
|
||||
pha
|
||||
lda cursor
|
||||
jsr setcursor
|
||||
L1: lda keyidx
|
||||
beq L1
|
||||
ldx #0
|
||||
pla
|
||||
bne L2
|
||||
inx
|
||||
L2: txa
|
||||
jsr setcursor
|
||||
lda CURS_FLAG
|
||||
pha
|
||||
lda cursor
|
||||
jsr setcursor
|
||||
L1: lda keyidx
|
||||
beq L1
|
||||
ldx #0
|
||||
pla
|
||||
bne L2
|
||||
inx
|
||||
L2: txa
|
||||
jsr setcursor
|
||||
|
||||
; Read the character from the keyboard buffer
|
||||
|
||||
L3: ldx #$00 ; Get index
|
||||
ldy keybuf ; Get first character in the buffer
|
||||
sei
|
||||
L4: lda keybuf+1,x ; Move up the remaining chars
|
||||
sta keybuf,x
|
||||
inx
|
||||
cpx keyidx
|
||||
bne L4
|
||||
dec keyidx
|
||||
cli
|
||||
L3: ldx #$00 ; Get index
|
||||
ldy keybuf ; Get first character in the buffer
|
||||
sei
|
||||
L4: lda keybuf+1,x ; Move up the remaining chars
|
||||
sta keybuf,x
|
||||
inx
|
||||
cpx keyidx
|
||||
bne L4
|
||||
dec keyidx
|
||||
cli
|
||||
|
||||
ldx #$00 ; High byte
|
||||
tya ; First char from buffer
|
||||
rts
|
||||
ldx #$00 ; High byte
|
||||
tya ; First char from buffer
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
;
|
||||
|
||||
.proc setcursor
|
||||
.proc setcursor
|
||||
|
||||
ldy #$00 ;
|
||||
tax ; On or off?
|
||||
bne @L9 ; Go set it on
|
||||
lda CURS_FLAG ; Is the cursor currently off?
|
||||
bne @L8 ; Jump if yes
|
||||
lda #1
|
||||
sta CURS_FLAG ; Mark it as off
|
||||
lda CURS_STATE ; Cursor currently displayed?
|
||||
sty CURS_STATE ; Cursor will be cleared later
|
||||
beq @L8 ; Jump if no
|
||||
ldy #$00 ;
|
||||
tax ; On or off?
|
||||
bne @L9 ; Go set it on
|
||||
lda CURS_FLAG ; Is the cursor currently off?
|
||||
bne @L8 ; Jump if yes
|
||||
lda #1
|
||||
sta CURS_FLAG ; Mark it as off
|
||||
lda CURS_STATE ; Cursor currently displayed?
|
||||
sty CURS_STATE ; Cursor will be cleared later
|
||||
beq @L8 ; Jump if no
|
||||
|
||||
; Switch to the system bank, load Y with the cursor X coordinate
|
||||
|
||||
lda #$0F
|
||||
sta IndReg ; Access system bank
|
||||
ldy CURS_X
|
||||
lda #$0F
|
||||
sta IndReg ; Access system bank
|
||||
ldy CURS_X
|
||||
|
||||
; Reset the current cursor
|
||||
|
||||
lda CURS_COLOR
|
||||
sta (CRAM_PTR),y ; Store cursor color
|
||||
lda ExecReg
|
||||
sta IndReg ; Switch to our segment
|
||||
lda (SCREEN_PTR),y
|
||||
eor #$80 ; Toggle reverse flag
|
||||
sta (SCREEN_PTR),y
|
||||
lda CURS_COLOR
|
||||
sta (CRAM_PTR),y ; Store cursor color
|
||||
lda ExecReg
|
||||
sta IndReg ; Switch to our segment
|
||||
lda (SCREEN_PTR),y
|
||||
eor #$80 ; Toggle reverse flag
|
||||
sta (SCREEN_PTR),y
|
||||
|
||||
; Done
|
||||
|
||||
@L8: rts
|
||||
@L8: rts
|
||||
|
||||
@L9: sty CURS_FLAG ; Cursor on (Y = 0)
|
||||
rts
|
||||
@L9: sty CURS_FLAG ; Cursor on (Y = 0)
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
@@ -103,48 +103,48 @@ L4: lda keybuf+1,x ; Move up the remaining chars
|
||||
|
||||
.proc k_blncur
|
||||
|
||||
lda CURS_FLAG ; Is the cursor on?
|
||||
bne curend ; Jump if not
|
||||
lda CURS_FLAG ; Is the cursor on?
|
||||
bne curend ; Jump if not
|
||||
dec CURS_BLINK
|
||||
bne curend
|
||||
|
||||
; Re-initialize the blink counter
|
||||
|
||||
lda #20 ; Initial value
|
||||
lda #20 ; Initial value
|
||||
sta CURS_BLINK
|
||||
|
||||
; Load Y with the cursor X coordinate
|
||||
|
||||
ldy CURS_X
|
||||
ldy CURS_X
|
||||
|
||||
; Check if the cursor state was on or off before
|
||||
|
||||
lda CURS_COLOR ; Load color behind cursor
|
||||
lsr CURS_STATE ; Cursor currently displayed?
|
||||
bcs curset ; Jump if yes
|
||||
lda CURS_COLOR ; Load color behind cursor
|
||||
lsr CURS_STATE ; Cursor currently displayed?
|
||||
bcs curset ; Jump if yes
|
||||
|
||||
; Cursor was off before, switch it on
|
||||
|
||||
inc CURS_STATE ; Mark as displayed
|
||||
lda (CRAM_PTR),y ; Get color behind cursor...
|
||||
sta CURS_COLOR ; ...and remember it
|
||||
lda CHARCOLOR ; Use character color
|
||||
inc CURS_STATE ; Mark as displayed
|
||||
lda (CRAM_PTR),y ; Get color behind cursor...
|
||||
sta CURS_COLOR ; ...and remember it
|
||||
lda CHARCOLOR ; Use character color
|
||||
|
||||
; Set the cursor with color in A
|
||||
|
||||
curset: sta (CRAM_PTR),y ; Store cursor color
|
||||
lda ExecReg
|
||||
sta IndReg ; Switch to our segment
|
||||
lda (SCREEN_PTR),y
|
||||
eor #$80 ; Toggle reverse flag
|
||||
sta (SCREEN_PTR),y
|
||||
curset: sta (CRAM_PTR),y ; Store cursor color
|
||||
lda ExecReg
|
||||
sta IndReg ; Switch to our segment
|
||||
lda (SCREEN_PTR),y
|
||||
eor #$80 ; Toggle reverse flag
|
||||
sta (SCREEN_PTR),y
|
||||
|
||||
; Switch back to the system bank
|
||||
|
||||
lda #$0F
|
||||
sta IndReg
|
||||
lda #$0F
|
||||
sta IndReg
|
||||
|
||||
curend: rts
|
||||
curend: rts
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
@@ -2,61 +2,61 @@
|
||||
; Ullrich von Bassewitz, 14.09.2001
|
||||
;
|
||||
|
||||
.export _clrscr
|
||||
.import plot
|
||||
.export _clrscr
|
||||
.import plot
|
||||
|
||||
.include "cbm510.inc"
|
||||
.include "cbm510.inc"
|
||||
.include "extzp.inc"
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; void clrscr (void);
|
||||
|
||||
.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
|
||||
|
||||
ldx #$00 ; Count
|
||||
jsr clearpage
|
||||
jsr clearpage
|
||||
jsr clearpage
|
||||
ldx #<(40*25) ; Count
|
||||
jsr clearpage ; Clear remainder of last page
|
||||
jmp plot ; Set screen pointer again
|
||||
ldx #$00 ; Count
|
||||
jsr clearpage
|
||||
jsr clearpage
|
||||
jsr clearpage
|
||||
ldx #<(40*25) ; Count
|
||||
jsr clearpage ; Clear remainder of last page
|
||||
jmp plot ; Set screen pointer again
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
.proc clearpage
|
||||
.proc clearpage
|
||||
|
||||
txa
|
||||
pha ; Save count
|
||||
txa
|
||||
pha ; Save count
|
||||
|
||||
lda #$20 ; Screencode for blank
|
||||
ldy #$00
|
||||
@L1: sta (SCREEN_PTR),y
|
||||
iny
|
||||
dex
|
||||
bne @L1
|
||||
inc SCREEN_PTR+1
|
||||
lda #$20 ; Screencode for blank
|
||||
ldy #$00
|
||||
@L1: sta (SCREEN_PTR),y
|
||||
iny
|
||||
dex
|
||||
bne @L1
|
||||
inc SCREEN_PTR+1
|
||||
|
||||
pla
|
||||
tax ; Reload count
|
||||
lda IndReg
|
||||
pha
|
||||
lda #$0F
|
||||
sta IndReg ; Switch to the system bank
|
||||
lda CHARCOLOR ; Load color
|
||||
ldy #$00
|
||||
@L2: sta (CRAM_PTR),y
|
||||
iny
|
||||
dex
|
||||
bne @L2
|
||||
inc CRAM_PTR+1
|
||||
pla
|
||||
sta IndReg ; Restore the old indirect bank
|
||||
rts
|
||||
pla
|
||||
tax ; Reload count
|
||||
lda IndReg
|
||||
pha
|
||||
lda #$0F
|
||||
sta IndReg ; Switch to the system bank
|
||||
lda CHARCOLOR ; Load color
|
||||
ldy #$00
|
||||
@L2: sta (CRAM_PTR),y
|
||||
iny
|
||||
dex
|
||||
bne @L2
|
||||
inc CRAM_PTR+1
|
||||
pla
|
||||
sta IndReg ; Restore the old indirect bank
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
; Ullrich von Bassewitz, 13.09.2001
|
||||
;
|
||||
|
||||
.export _textcolor, _bgcolor, _bordercolor
|
||||
.import sys_bank, restore_bank
|
||||
.import vic: zp, CHARCOLOR: zp
|
||||
.export _textcolor, _bgcolor, _bordercolor
|
||||
.import sys_bank, restore_bank
|
||||
.import vic: zp, CHARCOLOR: zp
|
||||
|
||||
.include "cbm510.inc"
|
||||
.include "cbm510.inc"
|
||||
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
@@ -14,12 +14,12 @@
|
||||
; /* Set the color for text output. The old color setting is returned. */
|
||||
;
|
||||
|
||||
.proc _textcolor
|
||||
.proc _textcolor
|
||||
|
||||
ldx CHARCOLOR ; get old value
|
||||
sta CHARCOLOR ; set new value
|
||||
txa
|
||||
rts
|
||||
ldx CHARCOLOR ; get old value
|
||||
sta CHARCOLOR ; set new value
|
||||
txa
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
@@ -30,15 +30,15 @@
|
||||
|
||||
.proc _bgcolor
|
||||
|
||||
jsr sys_bank ; Switch to the system bank
|
||||
pha ; Save new color
|
||||
ldy #VIC_BG_COLOR0
|
||||
lda (vic),y ; Get current color...
|
||||
tax ; ...into X
|
||||
pla ; Get new color
|
||||
sta (vic),y ; Set new color
|
||||
txa ; Get old color into X
|
||||
jmp restore_bank ; Restore the old color
|
||||
jsr sys_bank ; Switch to the system bank
|
||||
pha ; Save new color
|
||||
ldy #VIC_BG_COLOR0
|
||||
lda (vic),y ; Get current color...
|
||||
tax ; ...into X
|
||||
pla ; Get new color
|
||||
sta (vic),y ; Set new color
|
||||
txa ; Get old color into X
|
||||
jmp restore_bank ; Restore the old color
|
||||
|
||||
.endproc
|
||||
|
||||
@@ -46,17 +46,17 @@
|
||||
; unsigned char __fastcall__ bordercolor (unsigned char color);
|
||||
; /* Set the color for the border. The old color setting is returned. */
|
||||
|
||||
.proc _bordercolor
|
||||
.proc _bordercolor
|
||||
|
||||
jsr sys_bank ; Switch to the system bank
|
||||
pha ; Save new color
|
||||
ldy #VIC_BORDERCOLOR
|
||||
lda (vic),y ; Get current color...
|
||||
tax ; ...into X
|
||||
pla ; Get new color
|
||||
sta (vic),y ; Set new color
|
||||
txa ; Get old color into X
|
||||
jmp restore_bank ; Restore the old color
|
||||
jsr sys_bank ; Switch to the system bank
|
||||
pha ; Save new color
|
||||
ldy #VIC_BORDERCOLOR
|
||||
lda (vic),y ; Get current color...
|
||||
tax ; ...into X
|
||||
pla ; Get new color
|
||||
sta (vic),y ; Set new color
|
||||
txa ; Get old color into X
|
||||
jmp restore_bank ; Restore the old color
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
@@ -5,15 +5,15 @@
|
||||
; void cputc (char c);
|
||||
;
|
||||
|
||||
.export _cputcxy, _cputc, cputdirect, putchar
|
||||
.export newline, plot
|
||||
.export _cputcxy, _cputc, cputdirect, putchar
|
||||
.export newline, plot
|
||||
|
||||
.import popa, _gotoxy
|
||||
.import popa, _gotoxy
|
||||
.import __VIDRAM_START__
|
||||
.import CURS_X: zp, CURS_Y: zp, CHARCOLOR: zp, RVS: zp
|
||||
.import SCREEN_PTR: zp, CRAM_PTR: zp
|
||||
|
||||
.include "cbm510.inc"
|
||||
.include "cbm510.inc"
|
||||
|
||||
.macpack generic
|
||||
|
||||
@@ -21,89 +21,89 @@
|
||||
;
|
||||
|
||||
_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
|
||||
|
||||
advance:
|
||||
iny
|
||||
cpy #XSIZE
|
||||
bne L3
|
||||
jsr newline ; new line
|
||||
ldy #0 ; + cr
|
||||
L3: sty CURS_X
|
||||
rts
|
||||
iny
|
||||
cpy #XSIZE
|
||||
bne L3
|
||||
jsr newline ; new line
|
||||
ldy #0 ; + cr
|
||||
L3: sty CURS_X
|
||||
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
|
||||
|
||||
; Move the cursor into the next line
|
||||
|
||||
newline:
|
||||
inc CURS_Y
|
||||
inc CURS_Y
|
||||
|
||||
; Set cursor position, calculate RAM pointers
|
||||
|
||||
plot: ldx CURS_Y
|
||||
lda LineLSBTab,x
|
||||
sta SCREEN_PTR
|
||||
sta CRAM_PTR
|
||||
lda LineMSBTab,x
|
||||
sta SCREEN_PTR+1
|
||||
add #.hibyte(COLOR_RAM - __VIDRAM_START__)
|
||||
sta CRAM_PTR+1
|
||||
rts
|
||||
plot: ldx CURS_Y
|
||||
lda LineLSBTab,x
|
||||
sta SCREEN_PTR
|
||||
sta CRAM_PTR
|
||||
lda LineMSBTab,x
|
||||
sta SCREEN_PTR+1
|
||||
add #.hibyte(COLOR_RAM - __VIDRAM_START__)
|
||||
sta CRAM_PTR+1
|
||||
rts
|
||||
|
||||
; Write one character to the screen without doing anything else, return X
|
||||
; position in Y
|
||||
|
||||
putchar:
|
||||
ora RVS ; Set revers bit
|
||||
ldy CURS_X
|
||||
sta (SCREEN_PTR),y ; Set char
|
||||
ldx IndReg
|
||||
lda #$0F
|
||||
sta IndReg
|
||||
lda CHARCOLOR
|
||||
sta (CRAM_PTR),y ; Set color
|
||||
stx IndReg
|
||||
rts
|
||||
ora RVS ; Set revers bit
|
||||
ldy CURS_X
|
||||
sta (SCREEN_PTR),y ; Set char
|
||||
ldx IndReg
|
||||
lda #$0F
|
||||
sta IndReg
|
||||
lda CHARCOLOR
|
||||
sta (CRAM_PTR),y ; Set color
|
||||
stx IndReg
|
||||
rts
|
||||
|
||||
; -------------------------------------------------------------------------
|
||||
; Low bytes of the start address of the screen lines
|
||||
@@ -111,14 +111,14 @@ putchar:
|
||||
.rodata
|
||||
|
||||
LineLSBTab:
|
||||
.repeat 25, I
|
||||
.byte .lobyte(__VIDRAM_START__ + I * 40)
|
||||
.endrep
|
||||
.repeat 25, I
|
||||
.byte .lobyte(__VIDRAM_START__ + I * 40)
|
||||
.endrep
|
||||
|
||||
; -------------------------------------------------------------------------
|
||||
; High bytes of the start address of the screen lines
|
||||
|
||||
LineMSBTab:
|
||||
.repeat 25, I
|
||||
.byte .hibyte(__VIDRAM_START__ + I * 40)
|
||||
.endrep
|
||||
.repeat 25, I
|
||||
.byte .hibyte(__VIDRAM_START__ + I * 40)
|
||||
.endrep
|
||||
|
||||
@@ -2,19 +2,19 @@
|
||||
; Startup code for cc65 (CBM 500 version)
|
||||
;
|
||||
|
||||
.export _exit, BRKVec
|
||||
.export _exit, BRKVec
|
||||
.export __STARTUP__ : absolute = 1 ; Mark as startup
|
||||
|
||||
.import _clrscr, initlib, donelib, callirq_y
|
||||
.import push0, callmain
|
||||
.import __CHARRAM_START__, __CHARRAM_SIZE__, __VIDRAM_START__
|
||||
.import __BSS_RUN__, __BSS_SIZE__, __EXTZP_RUN__
|
||||
.import __INTERRUPTOR_COUNT__
|
||||
.import scnkey, UDTIM
|
||||
.import _clrscr, initlib, donelib, callirq_y
|
||||
.import push0, callmain
|
||||
.import __CHARRAM_START__, __CHARRAM_SIZE__, __VIDRAM_START__
|
||||
.import __BSS_RUN__, __BSS_SIZE__, __EXTZP_RUN__
|
||||
.import __INTERRUPTOR_COUNT__
|
||||
.import scnkey, UDTIM
|
||||
|
||||
.include "zeropage.inc"
|
||||
.include "zeropage.inc"
|
||||
.include "extzp.inc"
|
||||
.include "cbm510.inc"
|
||||
.include "cbm510.inc"
|
||||
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
@@ -37,8 +37,8 @@
|
||||
; The machine program in the data lines is:
|
||||
;
|
||||
; sei
|
||||
; lda #$00
|
||||
; sta $00 <-- Switch to bank 0 after this command
|
||||
; lda #$00
|
||||
; sta $00 <-- Switch to bank 0 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
|
||||
@@ -48,11 +48,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,$30,$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,$30,$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 #$00
|
||||
sta ExecReg
|
||||
sei
|
||||
lda #$00
|
||||
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 ; vic
|
||||
.word $da00 ; sid
|
||||
.word $db00 ; cia1
|
||||
.word $dc00 ; cia2
|
||||
.word $dd00 ; acia
|
||||
.word $de00 ; tpi1
|
||||
.word $df00 ; tpi2
|
||||
.word $eab1 ; ktab1
|
||||
.word $eb11 ; ktab2
|
||||
.word $eb71 ; ktab3
|
||||
.word $ebd1 ; ktab4
|
||||
.word $d800 ; vic
|
||||
.word $da00 ; sid
|
||||
.word $db00 ; cia1
|
||||
.word $dc00 ; cia2
|
||||
.word $dd00 ; acia
|
||||
.word $de00 ; tpi1
|
||||
.word $df00 ; tpi2
|
||||
.word $eab1 ; ktab1
|
||||
.word $eb11 ; ktab2
|
||||
.word $eb71 ; ktab3
|
||||
.word $ebd1 ; 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
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
@@ -349,32 +349,32 @@ Z4: jmp Init
|
||||
; Copy the character rom from the system bank into the execution bank
|
||||
|
||||
Init: lda #<$C000
|
||||
sta ptr1
|
||||
lda #>$C000
|
||||
sta ptr1+1
|
||||
lda #<__CHARRAM_START__
|
||||
sta ptr2
|
||||
lda #>__CHARRAM_START__
|
||||
sta ptr2+1
|
||||
lda #>__CHARRAM_SIZE__ ; 16 * 256 bytes to copy
|
||||
sta tmp1
|
||||
ldy #$00
|
||||
ccopy: lda #$0F
|
||||
sta IndReg ; Access the system bank
|
||||
ccopy1: lda (ptr1),y
|
||||
sta __VIDRAM_START__,y
|
||||
iny
|
||||
bne ccopy1
|
||||
lda ExecReg
|
||||
sta IndReg
|
||||
ccopy2: lda __VIDRAM_START__,y
|
||||
sta (ptr2),y
|
||||
iny
|
||||
bne ccopy2
|
||||
inc ptr1+1
|
||||
inc ptr2+1 ; Bump high pointer bytes
|
||||
dec tmp1
|
||||
bne ccopy
|
||||
sta ptr1
|
||||
lda #>$C000
|
||||
sta ptr1+1
|
||||
lda #<__CHARRAM_START__
|
||||
sta ptr2
|
||||
lda #>__CHARRAM_START__
|
||||
sta ptr2+1
|
||||
lda #>__CHARRAM_SIZE__ ; 16 * 256 bytes to copy
|
||||
sta tmp1
|
||||
ldy #$00
|
||||
ccopy: lda #$0F
|
||||
sta IndReg ; Access the system bank
|
||||
ccopy1: lda (ptr1),y
|
||||
sta __VIDRAM_START__,y
|
||||
iny
|
||||
bne ccopy1
|
||||
lda ExecReg
|
||||
sta IndReg
|
||||
ccopy2: lda __VIDRAM_START__,y
|
||||
sta (ptr2),y
|
||||
iny
|
||||
bne ccopy2
|
||||
inc ptr1+1
|
||||
inc ptr2+1 ; Bump high pointer bytes
|
||||
dec tmp1
|
||||
bne ccopy
|
||||
|
||||
; Clear the video memory. We will do this before switching the video to bank 0
|
||||
; to avoid garbage when doing so.
|
||||
@@ -384,67 +384,67 @@ ccopy2: lda __VIDRAM_START__,y
|
||||
; Reprogram the VIC so that the text screen and the character ROM is in the
|
||||
; execution bank. This is done in three steps:
|
||||
|
||||
lda #$0F ; We need access to the system bank
|
||||
sta IndReg
|
||||
lda #$0F ; We need access to the system bank
|
||||
sta IndReg
|
||||
|
||||
; Place the VIC video RAM into bank 0
|
||||
; CA (STATVID) = 0
|
||||
; CB (VICDOTSEL) = 0
|
||||
|
||||
ldy #TPI::CR
|
||||
lda (tpi1),y
|
||||
sta vidsave+0
|
||||
and #%00001111
|
||||
ora #%10100000
|
||||
sta (tpi1),y
|
||||
ldy #TPI::CR
|
||||
lda (tpi1),y
|
||||
sta vidsave+0
|
||||
and #%00001111
|
||||
ora #%10100000
|
||||
sta (tpi1),y
|
||||
|
||||
; Set bit 14/15 of the VIC address range to the high bits of __VIDRAM_START__
|
||||
; PC6/PC7 (VICBANKSEL 0/1) = 11
|
||||
|
||||
ldy #TPI::PRC
|
||||
lda (tpi2),y
|
||||
sta vidsave+1
|
||||
and #$3F
|
||||
ora #<((>__VIDRAM_START__) & $C0)
|
||||
sta (tpi2),y
|
||||
ldy #TPI::PRC
|
||||
lda (tpi2),y
|
||||
sta vidsave+1
|
||||
and #$3F
|
||||
ora #<((>__VIDRAM_START__) & $C0)
|
||||
sta (tpi2),y
|
||||
|
||||
; Set the VIC base address register to the addresses of the video and
|
||||
; character RAM.
|
||||
|
||||
ldy #VIC_VIDEO_ADR
|
||||
lda (vic),y
|
||||
sta vidsave+2
|
||||
and #$01
|
||||
ora #<(((__VIDRAM_START__ >> 6) & $F0) | ((__CHARRAM_START__ >> 10) & $0E) | $02)
|
||||
; and #$0F
|
||||
; ora #<(((>__VIDRAM_START__) << 2) & $F0)
|
||||
sta (vic),y
|
||||
ldy #VIC_VIDEO_ADR
|
||||
lda (vic),y
|
||||
sta vidsave+2
|
||||
and #$01
|
||||
ora #<(((__VIDRAM_START__ >> 6) & $F0) | ((__CHARRAM_START__ >> 10) & $0E) | $02)
|
||||
; and #$0F
|
||||
; ora #<(((>__VIDRAM_START__) << 2) & $F0)
|
||||
sta (vic),y
|
||||
|
||||
; Switch back to the execution bank
|
||||
|
||||
lda ExecReg
|
||||
sta IndReg
|
||||
sta IndReg
|
||||
|
||||
; Activate chained interrupt handlers, then enable interrupts.
|
||||
|
||||
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 on stack
|
||||
jsr donelib ; Run module destructors
|
||||
lda #$00
|
||||
_exit: pha ; Save the return code on stack
|
||||
jsr donelib ; Run module destructors
|
||||
lda #$00
|
||||
sta irqcount ; Disable custom irq handlers
|
||||
|
||||
; Address the system bank
|
||||
@@ -454,17 +454,17 @@ _exit: pha ; Save the return code on stack
|
||||
|
||||
; Switch back the video to the system bank
|
||||
|
||||
ldy #TPI::CR
|
||||
lda vidsave+0
|
||||
sta (tpi1),y
|
||||
ldy #TPI::CR
|
||||
lda vidsave+0
|
||||
sta (tpi1),y
|
||||
|
||||
ldy #TPI::PRC
|
||||
lda vidsave+1
|
||||
sta (tpi2),y
|
||||
ldy #TPI::PRC
|
||||
lda vidsave+1
|
||||
sta (tpi2),y
|
||||
|
||||
ldy #VIC_VIDEO_ADR
|
||||
lda vidsave+2
|
||||
sta (vic),y
|
||||
ldy #VIC_VIDEO_ADR
|
||||
lda vidsave+2
|
||||
sta (vic),y
|
||||
|
||||
; Copy stuff back from our zeropage to the systems
|
||||
|
||||
@@ -484,9 +484,9 @@ _exit: pha ; Save the return code on stack
|
||||
|
||||
; 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.
|
||||
|
||||
@@ -499,9 +499,9 @@ _exit: pha ; Save the return code on stack
|
||||
iny
|
||||
lda #$60 ; RTS opcode
|
||||
sta (sysp1),y
|
||||
lda IndReg
|
||||
lda IndReg
|
||||
sei
|
||||
txs
|
||||
txs
|
||||
jmp Back
|
||||
|
||||
; -------------------------------------------------------------------------
|
||||
@@ -509,7 +509,7 @@ _exit: pha ; Save the return code on stack
|
||||
; 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
|
||||
@@ -527,10 +527,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
|
||||
|
||||
@@ -538,46 +538,46 @@ 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
|
||||
|
||||
.data
|
||||
vidsave:.res 3
|
||||
vidsave:.res 3
|
||||
|
||||
.bss
|
||||
irqcount: .byte 0
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
; Oliver Schmidt, 2010-02-14
|
||||
;
|
||||
|
||||
.include "extzp.inc"
|
||||
.include "extzp.inc"
|
||||
|
||||
.exportzp devnum := DEVNUM
|
||||
.exportzp devnum := DEVNUM
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
; Ullrich von Bassewitz, 2002-12-09, 2003-12-27
|
||||
;
|
||||
|
||||
.include "zeropage.inc"
|
||||
.include "zeropage.inc"
|
||||
|
||||
.include "em-kernel.inc"
|
||||
.include "em-kernel.inc"
|
||||
.include "em-error.inc"
|
||||
.include "cbm510.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
|
||||
|
||||
|
||||
@@ -19,20 +19,20 @@
|
||||
; initializer table
|
||||
sysp1: .res 2
|
||||
sysp3: .res 2
|
||||
vic: .res 2
|
||||
sid: .res 2
|
||||
cia1: .res 2
|
||||
cia2: .res 2
|
||||
acia: .res 2
|
||||
tpi1: .res 2
|
||||
tpi2: .res 2
|
||||
ktab1: .res 2
|
||||
ktab2: .res 2
|
||||
ktab3: .res 2
|
||||
ktab4: .res 2
|
||||
vic: .res 2
|
||||
sid: .res 2
|
||||
cia1: .res 2
|
||||
cia2: .res 2
|
||||
acia: .res 2
|
||||
tpi1: .res 2
|
||||
tpi2: .res 2
|
||||
ktab1: .res 2
|
||||
ktab2: .res 2
|
||||
ktab3: .res 2
|
||||
ktab4: .res 2
|
||||
|
||||
sysp0: .word $0000
|
||||
time: .dword $0000
|
||||
time: .dword $0000
|
||||
segsave: .byte 0
|
||||
ktmp: .byte 0
|
||||
CURS_X: .byte 0
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
; IRQ handling (CBM 500 version)
|
||||
;
|
||||
|
||||
.export initirq, doneirq
|
||||
.export initirq, doneirq
|
||||
|
||||
initirq:
|
||||
doneirq:
|
||||
rts
|
||||
rts
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
; Ullrich von Bassewitz, 2003-02-16
|
||||
;
|
||||
|
||||
.include "zeropage.inc"
|
||||
.include "zeropage.inc"
|
||||
.include "../extzp.inc"
|
||||
|
||||
.include "joy-kernel.inc"
|
||||
.include "joy-kernel.inc"
|
||||
.include "joy-error.inc"
|
||||
.include "cbm510.inc"
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
; Driver signature
|
||||
|
||||
.byte $6A, $6F, $79 ; "joy"
|
||||
.byte $6A, $6F, $79 ; "joy"
|
||||
.byte JOY_API_VERSION ; Driver API version number
|
||||
|
||||
; Button state masks (8 values)
|
||||
@@ -66,7 +66,7 @@ JOY_COUNT = 2 ; Number of joysticks we support
|
||||
INSTALL:
|
||||
lda #<JOY_ERR_OK
|
||||
ldx #>JOY_ERR_OK
|
||||
; rts ; Run into UNINSTALL instead
|
||||
; rts ; Run into UNINSTALL instead
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; UNINSTALL routine. Is called before the driver is removed from memory.
|
||||
@@ -92,45 +92,45 @@ COUNT:
|
||||
|
||||
READ: ldx #$0F ; Switch to the system bank
|
||||
stx IndReg
|
||||
tax ; Save joystick number
|
||||
tax ; Save joystick number
|
||||
|
||||
; Get the direction bits
|
||||
|
||||
ldy #CIA::PRB
|
||||
lda (cia2),y ; Read joystick inputs
|
||||
sta tmp1
|
||||
ldy #CIA::PRB
|
||||
lda (cia2),y ; Read joystick inputs
|
||||
sta tmp1
|
||||
|
||||
; Get the fire bits
|
||||
|
||||
ldy #CIA::PRA
|
||||
lda (cia2),y
|
||||
lda (cia2),y
|
||||
|
||||
; Make the result value
|
||||
|
||||
cpx #$00 ; Joystick 0?
|
||||
bne @L1 ; Jump if no
|
||||
cpx #$00 ; Joystick 0?
|
||||
bne @L1 ; Jump if no
|
||||
|
||||
; Joystick 1, fire is in bit 6, direction in bit 0-3
|
||||
|
||||
asl a
|
||||
jmp @L2
|
||||
asl a
|
||||
jmp @L2
|
||||
|
||||
; Joystick 2, fire is in bit 7, direction in bit 5-7
|
||||
|
||||
@L1: ldx #$00 ; High byte of return value
|
||||
lsr tmp1
|
||||
lsr tmp1
|
||||
lsr tmp1
|
||||
lsr tmp1
|
||||
@L1: ldx #$00 ; High byte of return value
|
||||
lsr tmp1
|
||||
lsr tmp1
|
||||
lsr tmp1
|
||||
lsr tmp1
|
||||
|
||||
; Mask the relavant bits, get the fire bit
|
||||
|
||||
@L2: asl a ; Fire bit into carry
|
||||
lda tmp1
|
||||
and #$0F
|
||||
bcc @L3
|
||||
ora #$10
|
||||
@L3: eor #$1F ; All bits are inverted
|
||||
@L2: asl a ; Fire bit into carry
|
||||
lda tmp1
|
||||
and #$0F
|
||||
bcc @L3
|
||||
ora #$10
|
||||
@L3: eor #$1F ; All bits are inverted
|
||||
|
||||
; Switch back to the execution bank and return the joystick mask in a/x
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
; const void joy_static_stddrv[];
|
||||
;
|
||||
|
||||
.export _joy_static_stddrv
|
||||
.import _cbm510_std_joy
|
||||
.export _joy_static_stddrv
|
||||
.import _cbm510_std_joy
|
||||
|
||||
.rodata
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
; const char joy_stddrv[];
|
||||
;
|
||||
|
||||
.export _joy_stddrv
|
||||
.export _joy_stddrv
|
||||
|
||||
.rodata
|
||||
|
||||
_joy_stddrv: .asciiz "cbm510-std.joy"
|
||||
_joy_stddrv: .asciiz "cbm510-std.joy"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
|
||||
.proc IOBASE
|
||||
|
||||
ldx cia
|
||||
ldy cia+1
|
||||
rts
|
||||
ldx cia
|
||||
ldy cia+1
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -4,83 +4,83 @@
|
||||
; Keyboard polling stuff for the 510.
|
||||
;
|
||||
|
||||
.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 "cbm510.inc"
|
||||
.include "cbm510.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
|
||||
@@ -97,17 +97,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
|
||||
@@ -116,7 +116,7 @@ Repeat: dec rptdelay
|
||||
ldx keyidx
|
||||
bne End
|
||||
|
||||
PutKey: sta keybuf,x
|
||||
PutKey: sta keybuf,x
|
||||
inx
|
||||
stx keyidx
|
||||
ldx #$03
|
||||
@@ -128,14 +128,14 @@ PutKey: sta keybuf,x
|
||||
|
||||
; Poll the keyboard port until it's stable
|
||||
|
||||
.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
|
||||
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
|
||||
.proc SCREEN
|
||||
|
||||
ldx #40 ; Columns
|
||||
ldy #25 ; Lines
|
||||
rts
|
||||
ldx #40 ; Columns
|
||||
ldy #25 ; Lines
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
;
|
||||
|
||||
|
||||
.constructor initmainargs, 24
|
||||
.import __argc, __argv
|
||||
.constructor initmainargs, 24
|
||||
.import __argc, __argv
|
||||
|
||||
|
||||
;---------------------------------------------------------------------------
|
||||
|
||||
@@ -2,49 +2,49 @@
|
||||
; Ullrich von Bassewitz, 14.09.2001
|
||||
;
|
||||
|
||||
.export _peekbsys, _peekwsys
|
||||
.importzp ptr1
|
||||
.export _peekbsys, _peekwsys
|
||||
.importzp ptr1
|
||||
|
||||
.include "cbm510.inc"
|
||||
.include "cbm510.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
|
||||
|
||||
|
||||
@@ -4,46 +4,46 @@
|
||||
; 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 "cbm510.inc"
|
||||
.include "cbm510.inc"
|
||||
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
;
|
||||
|
||||
.proc _pokebsys
|
||||
.proc _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
|
||||
|
||||
.endproc
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
;
|
||||
|
||||
.proc _pokewsys
|
||||
.proc _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
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
; /* Initialize the random number generator */
|
||||
;
|
||||
|
||||
.export __randomize
|
||||
.import _srand
|
||||
.export __randomize
|
||||
.import _srand
|
||||
.importzp time
|
||||
|
||||
__randomize:
|
||||
|
||||
@@ -4,24 +4,24 @@
|
||||
; unsigned char revers (unsigned char onoff);
|
||||
;
|
||||
|
||||
.export _revers
|
||||
.export _revers
|
||||
.import RVS: zp
|
||||
|
||||
|
||||
.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
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
.include "../extzp.inc"
|
||||
.include "ser-kernel.inc"
|
||||
.include "ser-error.inc"
|
||||
.include "cbm510.inc"
|
||||
.include "cbm510.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
|
||||
|
||||
@@ -137,14 +137,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.
|
||||
@@ -154,22 +154,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.
|
||||
@@ -178,49 +178,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
|
||||
|
||||
@@ -235,43 +235,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.
|
||||
@@ -282,30 +282,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.
|
||||
@@ -316,11 +316,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
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
@@ -344,25 +344,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
|
||||
@@ -376,26 +376,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
|
||||
|
||||
@@ -405,13 +405,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
|
||||
|
||||
|
||||
@@ -12,65 +12,65 @@
|
||||
|
||||
.include "time.inc"
|
||||
.include "cbm510.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 (cia2),y
|
||||
bpl AM
|
||||
and #%01111111
|
||||
sed
|
||||
clc
|
||||
adc #$12
|
||||
cld
|
||||
AM: jsr BCD2dec
|
||||
sta TM + tm::tm_hour
|
||||
ldy #CIA::TODMIN
|
||||
lda (cia2),y
|
||||
jsr BCD2dec
|
||||
sta TM + tm::tm_min
|
||||
ldy #CIA::TODSEC
|
||||
lda (cia2),y
|
||||
jsr BCD2dec
|
||||
sta TM + tm::tm_sec
|
||||
ldy #CIA::TOD10
|
||||
lda (cia2),y ; Dummy read to unfreeze
|
||||
ldy #CIA::TODHR
|
||||
lda (cia2),y
|
||||
bpl AM
|
||||
and #%01111111
|
||||
sed
|
||||
clc
|
||||
adc #$12
|
||||
cld
|
||||
AM: jsr BCD2dec
|
||||
sta TM + tm::tm_hour
|
||||
ldy #CIA::TODMIN
|
||||
lda (cia2),y
|
||||
jsr BCD2dec
|
||||
sta TM + tm::tm_min
|
||||
ldy #CIA::TODSEC
|
||||
lda (cia2),y
|
||||
jsr BCD2dec
|
||||
sta TM + tm::tm_sec
|
||||
ldy #CIA::TOD10
|
||||
lda (cia2),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
|
||||
|
||||
Reference in New Issue
Block a user