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
|
||||
|
||||
@@ -5,65 +5,65 @@
|
||||
; void reset_brk (void);
|
||||
;
|
||||
|
||||
.export _set_brk, _reset_brk
|
||||
.destructor _reset_brk
|
||||
.export _brk_a, _brk_x, _brk_y, _brk_sr, _brk_pc
|
||||
.export _set_brk, _reset_brk
|
||||
.destructor _reset_brk
|
||||
.export _brk_a, _brk_x, _brk_y, _brk_sr, _brk_pc
|
||||
|
||||
.include "vic20.inc"
|
||||
.include "vic20.inc"
|
||||
|
||||
|
||||
.bss
|
||||
_brk_a: .res 1
|
||||
_brk_x: .res 1
|
||||
_brk_y: .res 1
|
||||
_brk_sr: .res 1
|
||||
_brk_pc: .res 2
|
||||
_brk_a: .res 1
|
||||
_brk_x: .res 1
|
||||
_brk_y: .res 1
|
||||
_brk_sr: .res 1
|
||||
_brk_pc: .res 2
|
||||
|
||||
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
|
||||
|
||||
@@ -71,37 +71,37 @@ 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_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
|
||||
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_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,58 +4,58 @@
|
||||
; char cgetc (void);
|
||||
;
|
||||
|
||||
.export _cgetc
|
||||
.import cursor
|
||||
.export _cgetc
|
||||
.import cursor
|
||||
|
||||
.include "vic20.inc"
|
||||
.include "vic20.inc"
|
||||
|
||||
_cgetc: lda KEY_COUNT ; Get number of characters
|
||||
bne L3 ; Jump if there are already chars waiting
|
||||
_cgetc: lda KEY_COUNT ; Get number of characters
|
||||
bne L3 ; Jump if there are already chars waiting
|
||||
|
||||
; Switch on the cursor if needed
|
||||
|
||||
lda CURS_FLAG
|
||||
pha
|
||||
lda cursor
|
||||
jsr setcursor
|
||||
L1: lda KEY_COUNT
|
||||
beq L1
|
||||
ldx #0
|
||||
pla
|
||||
bne L2
|
||||
inx
|
||||
L2: txa
|
||||
jsr setcursor
|
||||
lda CURS_FLAG
|
||||
pha
|
||||
lda cursor
|
||||
jsr setcursor
|
||||
L1: lda KEY_COUNT
|
||||
beq L1
|
||||
ldx #0
|
||||
pla
|
||||
bne L2
|
||||
inx
|
||||
L2: txa
|
||||
jsr setcursor
|
||||
|
||||
L3: jsr KBDREAD ; Read char and return in A
|
||||
ldx #0
|
||||
rts
|
||||
L3: jsr KBDREAD ; Read char and return in A
|
||||
ldx #0
|
||||
rts
|
||||
|
||||
|
||||
; Switch the cursor on or off
|
||||
|
||||
.proc setcursor
|
||||
.proc setcursor
|
||||
|
||||
tax ; On or off?
|
||||
bne seton ; Go set it on
|
||||
lda CURS_FLAG ; Is the cursor currently off?
|
||||
bne crs9 ; Jump if yes
|
||||
lda #1
|
||||
sta CURS_FLAG ; Mark it as off
|
||||
lda CURS_STATE ; Cursor currently displayed?
|
||||
beq crs8 ; Jump if no
|
||||
ldy CURS_X ; Get the character column
|
||||
lda (SCREEN_PTR),y ; Get character
|
||||
eor #$80
|
||||
sta (SCREEN_PTR),y ; Store character back
|
||||
lda CURS_COLOR
|
||||
sta (CRAM_PTR),y ; Store color back
|
||||
crs8: lda #0
|
||||
sta CURS_STATE ; Cursor not displayed
|
||||
crs9: rts
|
||||
tax ; On or off?
|
||||
bne seton ; Go set it on
|
||||
lda CURS_FLAG ; Is the cursor currently off?
|
||||
bne crs9 ; Jump if yes
|
||||
lda #1
|
||||
sta CURS_FLAG ; Mark it as off
|
||||
lda CURS_STATE ; Cursor currently displayed?
|
||||
beq crs8 ; Jump if no
|
||||
ldy CURS_X ; Get the character column
|
||||
lda (SCREEN_PTR),y ; Get character
|
||||
eor #$80
|
||||
sta (SCREEN_PTR),y ; Store character back
|
||||
lda CURS_COLOR
|
||||
sta (CRAM_PTR),y ; Store color back
|
||||
crs8: lda #0
|
||||
sta CURS_STATE ; Cursor not displayed
|
||||
crs9: rts
|
||||
|
||||
seton: lda #0
|
||||
sta CURS_FLAG
|
||||
rts
|
||||
seton: lda #0
|
||||
sta CURS_FLAG
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
; void clrscr (void);
|
||||
;
|
||||
|
||||
.export _clrscr
|
||||
.export _clrscr
|
||||
|
||||
.include "vic20.inc"
|
||||
.include "vic20.inc"
|
||||
|
||||
_clrscr = CLRSCR
|
||||
|
||||
|
||||
@@ -8,53 +8,53 @@
|
||||
;
|
||||
|
||||
|
||||
.export _textcolor, _bgcolor, _bordercolor
|
||||
.importzp tmp1
|
||||
.export _textcolor, _bgcolor, _bordercolor
|
||||
.importzp tmp1
|
||||
|
||||
.include "vic20.inc"
|
||||
.include "vic20.inc"
|
||||
|
||||
|
||||
|
||||
.code
|
||||
|
||||
_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
|
||||
|
||||
|
||||
_bgcolor:
|
||||
asl
|
||||
asl
|
||||
asl
|
||||
asl
|
||||
sta tmp1
|
||||
sei ; don't want anything messing around while we update
|
||||
lda VIC_COLOR ; get old value
|
||||
and #$0F
|
||||
tax
|
||||
ora tmp1
|
||||
sta VIC_COLOR ; set new value
|
||||
cli
|
||||
txa
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
rts
|
||||
asl
|
||||
asl
|
||||
asl
|
||||
asl
|
||||
sta tmp1
|
||||
sei ; don't want anything messing around while we update
|
||||
lda VIC_COLOR ; get old value
|
||||
and #$0F
|
||||
tax
|
||||
ora tmp1
|
||||
sta VIC_COLOR ; set new value
|
||||
cli
|
||||
txa
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
rts
|
||||
|
||||
|
||||
_bordercolor:
|
||||
and #$07
|
||||
sta tmp1
|
||||
sei ; don't want anything messing around while we update
|
||||
lda VIC_COLOR ; get old value
|
||||
and #$F8
|
||||
tax
|
||||
ora tmp1
|
||||
sta VIC_COLOR ; set new value
|
||||
cli
|
||||
txa
|
||||
rts
|
||||
and #$07
|
||||
sta tmp1
|
||||
sei ; don't want anything messing around while we update
|
||||
lda VIC_COLOR ; get old value
|
||||
and #$F8
|
||||
tax
|
||||
ora tmp1
|
||||
sta VIC_COLOR ; set new value
|
||||
cli
|
||||
txa
|
||||
rts
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
; Low level stuff for screen output/console input
|
||||
;
|
||||
|
||||
.exportzp CURS_X, CURS_Y
|
||||
.exportzp CURS_X, CURS_Y
|
||||
|
||||
.include "vic20.inc"
|
||||
.include "vic20.inc"
|
||||
|
||||
|
||||
@@ -5,91 +5,91 @@
|
||||
; void cputc (char c);
|
||||
;
|
||||
|
||||
.export _cputcxy, _cputc, cputdirect, putchar
|
||||
.export newline, plot
|
||||
.import popa, _gotoxy
|
||||
.export _cputcxy, _cputc, cputdirect, putchar
|
||||
.export newline, plot
|
||||
.import popa, _gotoxy
|
||||
.import PLOT
|
||||
|
||||
.include "vic20.inc"
|
||||
.include "vic20.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
|
||||
|
||||
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
|
||||
|
||||
newline:
|
||||
clc
|
||||
lda #XSIZE
|
||||
adc SCREEN_PTR
|
||||
sta SCREEN_PTR
|
||||
bcc L4
|
||||
inc SCREEN_PTR+1
|
||||
clc
|
||||
L4: lda #XSIZE
|
||||
adc CRAM_PTR
|
||||
sta CRAM_PTR
|
||||
bcc L5
|
||||
inc CRAM_PTR+1
|
||||
L5: inc CURS_Y
|
||||
rts
|
||||
clc
|
||||
lda #XSIZE
|
||||
adc SCREEN_PTR
|
||||
sta SCREEN_PTR
|
||||
bcc L4
|
||||
inc SCREEN_PTR+1
|
||||
clc
|
||||
L4: lda #XSIZE
|
||||
adc CRAM_PTR
|
||||
sta CRAM_PTR
|
||||
bcc L5
|
||||
inc CRAM_PTR+1
|
||||
L5: 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
|
||||
L10: and #$7F
|
||||
cmp #$7E ; PI?
|
||||
bne L11
|
||||
lda #$5E ; Load screen code for PI
|
||||
bne cputdirect
|
||||
L11: ora #$40
|
||||
bne cputdirect
|
||||
|
||||
|
||||
|
||||
; Set cursor position, calculate RAM pointers
|
||||
|
||||
plot: ldy CURS_X
|
||||
ldx CURS_Y
|
||||
clc
|
||||
jmp PLOT ; Set the new cursor
|
||||
plot: ldy CURS_X
|
||||
ldx CURS_Y
|
||||
clc
|
||||
jmp PLOT ; Set the new cursor
|
||||
|
||||
|
||||
|
||||
@@ -97,9 +97,9 @@ plot: ldy CURS_X
|
||||
; position in Y
|
||||
|
||||
putchar:
|
||||
ora RVS ; Set revers bit
|
||||
ldy CURS_X
|
||||
sta (SCREEN_PTR),y ; Set char
|
||||
lda CHARCOLOR
|
||||
sta (CRAM_PTR),y ; Set color
|
||||
rts
|
||||
ora RVS ; Set revers bit
|
||||
ldy CURS_X
|
||||
sta (SCREEN_PTR),y ; Set char
|
||||
lda CHARCOLOR
|
||||
sta (CRAM_PTR),y ; Set color
|
||||
rts
|
||||
|
||||
@@ -2,96 +2,96 @@
|
||||
; Startup code for cc65 (Vic20 version)
|
||||
;
|
||||
|
||||
.export _exit
|
||||
.export __STARTUP__ : absolute = 1 ; Mark as startup
|
||||
.import initlib, donelib
|
||||
.import zerobss, push0
|
||||
.import callmain
|
||||
.import RESTOR, BSOUT, CLRCH
|
||||
.import __RAM_START__, __RAM_SIZE__ ; Linker generated
|
||||
.import __STACKSIZE__ ; Linker generated
|
||||
.importzp ST
|
||||
.export _exit
|
||||
.export __STARTUP__ : absolute = 1 ; Mark as startup
|
||||
.import initlib, donelib
|
||||
.import zerobss, push0
|
||||
.import callmain
|
||||
.import RESTOR, BSOUT, CLRCH
|
||||
.import __RAM_START__, __RAM_SIZE__ ; Linker generated
|
||||
.import __STACKSIZE__ ; Linker generated
|
||||
.importzp ST
|
||||
|
||||
.include "zeropage.inc"
|
||||
.include "vic20.inc"
|
||||
.include "zeropage.inc"
|
||||
.include "vic20.inc"
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Startup code
|
||||
|
||||
.segment "STARTUP"
|
||||
.segment "STARTUP"
|
||||
|
||||
Start:
|
||||
|
||||
; Save the zero page locations we need
|
||||
|
||||
ldx #zpspace-1
|
||||
L1: lda sp,x
|
||||
sta zpsave,x
|
||||
dex
|
||||
bpl L1
|
||||
ldx #zpspace-1
|
||||
L1: lda sp,x
|
||||
sta zpsave,x
|
||||
dex
|
||||
bpl L1
|
||||
|
||||
; Switch to second charset
|
||||
|
||||
lda #14
|
||||
jsr BSOUT
|
||||
lda #14
|
||||
jsr BSOUT
|
||||
|
||||
; Clear the BSS data
|
||||
|
||||
jsr zerobss
|
||||
jsr zerobss
|
||||
|
||||
; Save system stuff and setup the stack
|
||||
|
||||
tsx
|
||||
stx spsave ; Save the system stack ptr
|
||||
tsx
|
||||
stx spsave ; Save the system stack ptr
|
||||
|
||||
lda #<(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
|
||||
sta sp
|
||||
lda #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
|
||||
sta sp+1 ; Set argument stack ptr
|
||||
lda #<(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
|
||||
sta sp
|
||||
lda #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
|
||||
sta sp+1 ; Set argument stack ptr
|
||||
|
||||
; Call module constructors
|
||||
|
||||
jsr initlib
|
||||
jsr initlib
|
||||
|
||||
; Push arguments and call main()
|
||||
|
||||
jsr callmain
|
||||
jsr callmain
|
||||
|
||||
; Back from main (This is also the _exit entry). Run module destructors
|
||||
|
||||
_exit: pha ; Save the return code on stack
|
||||
jsr donelib
|
||||
_exit: pha ; Save the return code on stack
|
||||
jsr donelib
|
||||
|
||||
; Copy back the zero page stuff
|
||||
|
||||
ldx #zpspace-1
|
||||
L2: lda zpsave,x
|
||||
sta sp,x
|
||||
dex
|
||||
bpl L2
|
||||
ldx #zpspace-1
|
||||
L2: lda zpsave,x
|
||||
sta sp,x
|
||||
dex
|
||||
bpl L2
|
||||
|
||||
; Place the program return code into ST
|
||||
|
||||
pla
|
||||
sta ST
|
||||
pla
|
||||
sta ST
|
||||
|
||||
; Restore the stack pointer
|
||||
|
||||
ldx spsave
|
||||
txs
|
||||
ldx spsave
|
||||
txs
|
||||
|
||||
; Back to basic
|
||||
|
||||
rts
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
|
||||
.segment "ZPSAVE"
|
||||
.segment "ZPSAVE"
|
||||
|
||||
zpsave: .res zpspace
|
||||
zpsave: .res zpspace
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
|
||||
.bss
|
||||
|
||||
spsave: .res 1
|
||||
spsave: .res 1
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
; Oliver Schmidt, 2010-02-14
|
||||
;
|
||||
|
||||
.include "vic20.inc"
|
||||
.include "vic20.inc"
|
||||
|
||||
.exportzp devnum := DEVNUM
|
||||
.exportzp devnum := DEVNUM
|
||||
|
||||
@@ -6,26 +6,26 @@
|
||||
; /* Return the video mode the machine is using */
|
||||
;
|
||||
|
||||
.include "vic20.inc"
|
||||
.include "get_tv.inc"
|
||||
.include "vic20.inc"
|
||||
.include "get_tv.inc"
|
||||
|
||||
;--------------------------------------------------------------------------
|
||||
; _get_tv
|
||||
|
||||
.proc _get_tv
|
||||
.proc _get_tv
|
||||
|
||||
NTSC_LINES = 261
|
||||
; detect the system
|
||||
lda #TV::NTSC
|
||||
tax
|
||||
@L0: ldy VIC_HLINE
|
||||
cpy #1
|
||||
bne @L0 ; wait for line 1
|
||||
@L1: ldy VIC_HLINE
|
||||
beq @L2 ; line 0 reached -> NTSC
|
||||
cpy #NTSC_LINES/2+2
|
||||
bne @L1
|
||||
lda #TV::PAL
|
||||
@L2: rts ; system detected: 0 for NTSC, 1 for PAL
|
||||
; detect the system
|
||||
lda #TV::NTSC
|
||||
tax
|
||||
@L0: ldy VIC_HLINE
|
||||
cpy #1
|
||||
bne @L0 ; wait for line 1
|
||||
@L1: ldy VIC_HLINE
|
||||
beq @L2 ; line 0 reached -> NTSC
|
||||
cpy #NTSC_LINES/2+2
|
||||
bne @L1
|
||||
lda #TV::PAL
|
||||
@L2: rts ; system detected: 0 for NTSC, 1 for PAL
|
||||
|
||||
.endproc
|
||||
|
||||
@@ -2,48 +2,48 @@
|
||||
; IRQ handling (Vic20 version)
|
||||
;
|
||||
|
||||
.export initirq, doneirq
|
||||
.import callirq
|
||||
.export initirq, doneirq
|
||||
.import callirq
|
||||
|
||||
.include "vic20.inc"
|
||||
.include "vic20.inc"
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
|
||||
.segment "INIT"
|
||||
.segment "INIT"
|
||||
|
||||
initirq:
|
||||
lda IRQVec
|
||||
ldx IRQVec+1
|
||||
sta IRQInd+1
|
||||
stx IRQInd+2
|
||||
lda #<IRQStub
|
||||
ldx #>IRQStub
|
||||
jmp setvec
|
||||
lda IRQVec
|
||||
ldx IRQVec+1
|
||||
sta IRQInd+1
|
||||
stx IRQInd+2
|
||||
lda #<IRQStub
|
||||
ldx #>IRQStub
|
||||
jmp setvec
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
|
||||
.code
|
||||
|
||||
doneirq:
|
||||
lda IRQInd+1
|
||||
ldx IRQInd+2
|
||||
setvec: sei
|
||||
sta IRQVec
|
||||
stx IRQVec+1
|
||||
cli
|
||||
rts
|
||||
lda IRQInd+1
|
||||
ldx IRQInd+2
|
||||
setvec: sei
|
||||
sta IRQVec
|
||||
stx IRQVec+1
|
||||
cli
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
|
||||
.segment "LOWCODE"
|
||||
.segment "LOWCODE"
|
||||
|
||||
IRQStub:
|
||||
cld ; Just to be sure
|
||||
jsr callirq ; Call the functions
|
||||
jmp IRQInd ; Jump to the saved IRQ vector
|
||||
cld ; Just to be sure
|
||||
jsr callirq ; Call the functions
|
||||
jmp IRQInd ; Jump to the saved IRQ vector
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
|
||||
.data
|
||||
|
||||
IRQInd: jmp $0000
|
||||
IRQInd: jmp $0000
|
||||
|
||||
@@ -7,46 +7,46 @@
|
||||
; Using code from Steve Schmidtke
|
||||
;
|
||||
|
||||
.include "zeropage.inc"
|
||||
.include "zeropage.inc"
|
||||
|
||||
.include "joy-kernel.inc"
|
||||
.include "joy-error.inc"
|
||||
.include "vic20.inc"
|
||||
.include "joy-kernel.inc"
|
||||
.include "joy-error.inc"
|
||||
.include "vic20.inc"
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Header. Includes jump table
|
||||
|
||||
.segment "JUMPTABLE"
|
||||
.segment "JUMPTABLE"
|
||||
|
||||
; Driver signature
|
||||
|
||||
.byte $6A, $6F, $79 ; "joy"
|
||||
.byte JOY_API_VERSION ; Driver API version number
|
||||
.byte $6A, $6F, $79 ; "joy"
|
||||
.byte JOY_API_VERSION ; Driver API version number
|
||||
|
||||
; Button state masks (8 values)
|
||||
|
||||
.byte $01 ; JOY_UP
|
||||
.byte $02 ; JOY_DOWN
|
||||
.byte $04 ; JOY_LEFT
|
||||
.byte $08 ; JOY_RIGHT
|
||||
.byte $10 ; JOY_FIRE
|
||||
.byte $00 ; JOY_FIRE2 unavailable
|
||||
.byte $00 ; Future expansion
|
||||
.byte $00 ; Future expansion
|
||||
.byte $01 ; JOY_UP
|
||||
.byte $02 ; JOY_DOWN
|
||||
.byte $04 ; JOY_LEFT
|
||||
.byte $08 ; JOY_RIGHT
|
||||
.byte $10 ; JOY_FIRE
|
||||
.byte $00 ; JOY_FIRE2 unavailable
|
||||
.byte $00 ; Future expansion
|
||||
.byte $00 ; Future expansion
|
||||
|
||||
; Jump table.
|
||||
|
||||
.addr INSTALL
|
||||
.addr UNINSTALL
|
||||
.addr COUNT
|
||||
.addr READ
|
||||
.addr 0 ; IRQ entry unused
|
||||
.addr INSTALL
|
||||
.addr UNINSTALL
|
||||
.addr COUNT
|
||||
.addr READ
|
||||
.addr 0 ; IRQ entry unused
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Constants
|
||||
|
||||
VIA1_PRB := VIA1 ; User port register
|
||||
JOY_COUNT = 3 ; Number of joysticks we support
|
||||
VIA1_PRB := VIA1 ; User port register
|
||||
JOY_COUNT = 3 ; Number of joysticks we support
|
||||
|
||||
|
||||
.code
|
||||
@@ -59,9 +59,9 @@ JOY_COUNT = 3 ; Number of joysticks we support
|
||||
;
|
||||
|
||||
INSTALL:
|
||||
lda #<JOY_ERR_OK
|
||||
ldx #>JOY_ERR_OK
|
||||
; rts ; Run into UNINSTALL instead
|
||||
lda #<JOY_ERR_OK
|
||||
ldx #>JOY_ERR_OK
|
||||
; rts ; Run into UNINSTALL instead
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; UNINSTALL routine. Is called before the driver is removed from memory.
|
||||
@@ -69,7 +69,7 @@ INSTALL:
|
||||
;
|
||||
|
||||
UNINSTALL:
|
||||
rts
|
||||
rts
|
||||
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
@@ -77,72 +77,72 @@ UNINSTALL:
|
||||
;
|
||||
|
||||
COUNT:
|
||||
lda #<JOY_COUNT
|
||||
ldx #>JOY_COUNT
|
||||
rts
|
||||
lda #<JOY_COUNT
|
||||
ldx #>JOY_COUNT
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; READ: Read a particular joystick passed in A.
|
||||
;
|
||||
|
||||
READ: tax ; Joystick number into X
|
||||
bne joy2
|
||||
READ: tax ; Joystick number into X
|
||||
bne joy2
|
||||
|
||||
; Read joystick 1
|
||||
|
||||
joy1: lda #$7F ; mask for VIA2 JOYBIT: sw3
|
||||
ldx #$C3 ; mask for VIA1 JOYBITS: sw0,sw1,sw2,sw4
|
||||
sei ; necessary?
|
||||
joy1: lda #$7F ; mask for VIA2 JOYBIT: sw3
|
||||
ldx #$C3 ; mask for VIA1 JOYBITS: sw0,sw1,sw2,sw4
|
||||
sei ; necessary?
|
||||
|
||||
ldy VIA2_DDRB ; remember the date of DDRB
|
||||
sta VIA2_DDRB ; set JOYBITS on this VIA for input
|
||||
lda VIA2_JOY ; read JOYBIT: sw3
|
||||
sty VIA2_DDRB ; restore the state of DDRB
|
||||
asl ; Shift sw3 into carry
|
||||
ldy VIA2_DDRB ; remember the date of DDRB
|
||||
sta VIA2_DDRB ; set JOYBITS on this VIA for input
|
||||
lda VIA2_JOY ; read JOYBIT: sw3
|
||||
sty VIA2_DDRB ; restore the state of DDRB
|
||||
asl ; Shift sw3 into carry
|
||||
|
||||
ldy VIA1_DDRA ; remember the state of DDRA
|
||||
stx VIA1_DDRA ; set JOYBITS on this VIA for input
|
||||
lda VIA1_JOY ; read JOYBITS: sw0,sw1,sw2,sw4
|
||||
sty VIA1_DDRA ; restore the state of DDRA
|
||||
ldy VIA1_DDRA ; remember the state of DDRA
|
||||
stx VIA1_DDRA ; set JOYBITS on this VIA for input
|
||||
lda VIA1_JOY ; read JOYBITS: sw0,sw1,sw2,sw4
|
||||
sty VIA1_DDRA ; restore the state of DDRA
|
||||
|
||||
cli ; necessary?
|
||||
ror ; Shift sw3 into bit 7
|
||||
and #$9E ; Mask relevant bits
|
||||
eor #$9E ; Active states are inverted
|
||||
cli ; necessary?
|
||||
ror ; Shift sw3 into bit 7
|
||||
and #$9E ; Mask relevant bits
|
||||
eor #$9E ; Active states are inverted
|
||||
|
||||
rts
|
||||
rts
|
||||
|
||||
; Read joystick 2
|
||||
|
||||
joy2: lda #%10000000 ; via port B Data-Direction
|
||||
sta VIA1_DDRB ; bit 7: out bit 6-0: in
|
||||
joy2: lda #%10000000 ; via port B Data-Direction
|
||||
sta VIA1_DDRB ; bit 7: out bit 6-0: in
|
||||
|
||||
dex
|
||||
bne joy3
|
||||
dex
|
||||
bne joy3
|
||||
|
||||
lda #$80 ; via port B read/write
|
||||
sta VIA1_PRB ; (output one at PB7)
|
||||
lda #$80 ; via port B read/write
|
||||
sta VIA1_PRB ; (output one at PB7)
|
||||
|
||||
lda VIA1_PRB ; via port B read/write
|
||||
and #$1f ; get bit 4-0 (PB4-PB0)
|
||||
eor #$1f
|
||||
rts
|
||||
lda VIA1_PRB ; via port B read/write
|
||||
and #$1f ; get bit 4-0 (PB4-PB0)
|
||||
eor #$1f
|
||||
rts
|
||||
|
||||
; Read joystick 3
|
||||
|
||||
joy3: lda #$00 ; via port B read/write
|
||||
sta VIA1_PRB ; (output zero at PB7)
|
||||
joy3: lda #$00 ; via port B read/write
|
||||
sta VIA1_PRB ; (output zero at PB7)
|
||||
|
||||
lda VIA1_PRB ; via port B read/write
|
||||
and #$0f ; get bit 3-0 (PB3-PB0)
|
||||
sta tmp1 ; joy 4 directions
|
||||
lda VIA1_PRB ; via port B read/write
|
||||
and #$0f ; get bit 3-0 (PB3-PB0)
|
||||
sta tmp1 ; joy 4 directions
|
||||
|
||||
lda VIA1_PRB ; via port B read/write
|
||||
and #%00100000 ; get bit 5 (PB5)
|
||||
lsr
|
||||
ora tmp1
|
||||
eor #$1f
|
||||
lda VIA1_PRB ; via port B read/write
|
||||
and #%00100000 ; get bit 5 (PB5)
|
||||
lsr
|
||||
ora tmp1
|
||||
eor #$1f
|
||||
|
||||
ldx #0
|
||||
rts
|
||||
ldx #0
|
||||
rts
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
; Using code from Steve Schmidtke
|
||||
;
|
||||
|
||||
.include "zeropage.inc"
|
||||
.include "zeropage.inc"
|
||||
|
||||
.include "joy-kernel.inc"
|
||||
.include "joy-kernel.inc"
|
||||
.include "joy-error.inc"
|
||||
.include "vic20.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 = 1 ; 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.
|
||||
@@ -91,7 +91,7 @@ COUNT:
|
||||
; The current implemenation will ignore the joystick number because we do only
|
||||
; have one joystick
|
||||
|
||||
READ: lda #$7F ; mask for VIA2 JOYBIT: sw3
|
||||
READ: lda #$7F ; mask for VIA2 JOYBIT: sw3
|
||||
ldx #$C3 ; mask for VIA1 JOYBITS: sw0,sw1,sw2,sw4
|
||||
sei ; necessary?
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
; const void joy_static_stddrv[];
|
||||
;
|
||||
|
||||
.export _joy_static_stddrv
|
||||
.import _vic20_stdjoy_joy
|
||||
.export _joy_static_stddrv
|
||||
.import _vic20_stdjoy_joy
|
||||
|
||||
.rodata
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
; const char joy_stddrv[];
|
||||
;
|
||||
|
||||
.export _joy_stddrv
|
||||
.export _joy_stddrv
|
||||
|
||||
.rodata
|
||||
|
||||
_joy_stddrv: .asciiz "vic20-stdjoy.joy"
|
||||
_joy_stddrv: .asciiz "vic20-stdjoy.joy"
|
||||
|
||||
|
||||
@@ -4,15 +4,15 @@
|
||||
; unsigned char kbhit (void);
|
||||
;
|
||||
|
||||
.export _kbhit
|
||||
.export _kbhit
|
||||
|
||||
.include "vic20.inc"
|
||||
.include "vic20.inc"
|
||||
|
||||
|
||||
.proc _kbhit
|
||||
|
||||
ldx #0 ; High byte of return is always zero
|
||||
lda KEY_COUNT ; Get number of characters
|
||||
lda KEY_COUNT ; Get number of characters
|
||||
beq L9
|
||||
lda #1
|
||||
L9: rts
|
||||
|
||||
@@ -47,42 +47,42 @@
|
||||
;-----------------------------------------------------------------------------
|
||||
; All functions are available in the kernal jump table
|
||||
|
||||
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
|
||||
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
|
||||
IOBASE = $FFF3
|
||||
|
||||
|
||||
@@ -22,16 +22,16 @@
|
||||
; - The "file-name" might be a path-name; don't copy the directory-components.
|
||||
; - Add a control-character quoting mechanism.
|
||||
|
||||
.constructor initmainargs, 24
|
||||
.import __argc, __argv
|
||||
.constructor initmainargs, 24
|
||||
.import __argc, __argv
|
||||
|
||||
.include "vic20.inc"
|
||||
.include "vic20.inc"
|
||||
|
||||
|
||||
|
||||
MAXARGS = 10 ; Maximum number of arguments allowed
|
||||
REM = $8f ; BASIC token-code
|
||||
NAME_LEN = 16 ; maximum length of command-name
|
||||
MAXARGS = 10 ; Maximum number of arguments allowed
|
||||
REM = $8f ; BASIC token-code
|
||||
NAME_LEN = 16 ; maximum length of command-name
|
||||
|
||||
; Get possible command-line arguments. Goes into the special INIT segment,
|
||||
; which may be reused after the startup code is run
|
||||
@@ -45,25 +45,25 @@ initmainargs:
|
||||
; Because the buffer, that we're copying into, was zeroed out,
|
||||
; we don't need to add a NUL character.
|
||||
;
|
||||
ldy FNAM_LEN
|
||||
cpy #NAME_LEN + 1
|
||||
bcc L1
|
||||
ldy #NAME_LEN - 1 ; limit the length
|
||||
L0: lda (FNAM),y
|
||||
sta name,y
|
||||
L1: dey
|
||||
bpl L0
|
||||
inc __argc ; argc always is equal to, at least, 1
|
||||
ldy FNAM_LEN
|
||||
cpy #NAME_LEN + 1
|
||||
bcc L1
|
||||
ldy #NAME_LEN - 1 ; limit the length
|
||||
L0: lda (FNAM),y
|
||||
sta name,y
|
||||
L1: dey
|
||||
bpl L0
|
||||
inc __argc ; argc always is equal to, at least, 1
|
||||
|
||||
; Find the "rem" token.
|
||||
;
|
||||
ldx #0
|
||||
L2: lda BASIC_BUF,x
|
||||
beq done ; no "rem," no args.
|
||||
inx
|
||||
cmp #REM
|
||||
bne L2
|
||||
ldy #1 * 2
|
||||
ldx #0
|
||||
L2: lda BASIC_BUF,x
|
||||
beq done ; no "rem," no args.
|
||||
inx
|
||||
cmp #REM
|
||||
bne L2
|
||||
ldy #1 * 2
|
||||
|
||||
; Find the next argument
|
||||
|
||||
@@ -89,11 +89,11 @@ setterm:sta term ; Set end of argument marker
|
||||
; necessary.
|
||||
|
||||
txa ; Get low byte
|
||||
sta argv,y ; argv[y]= &arg
|
||||
iny
|
||||
lda #>BASIC_BUF
|
||||
sta argv,y
|
||||
iny
|
||||
sta argv,y ; argv[y]= &arg
|
||||
iny
|
||||
lda #>BASIC_BUF
|
||||
sta argv,y
|
||||
iny
|
||||
inc __argc ; Found another arg
|
||||
|
||||
; Search for the end of the argument
|
||||
@@ -120,21 +120,21 @@ argloop:lda BASIC_BUF,x
|
||||
|
||||
; (The last vector in argv[] already is NULL.)
|
||||
|
||||
done: lda #<argv
|
||||
ldx #>argv
|
||||
sta __argv
|
||||
stx __argv + 1
|
||||
rts
|
||||
done: lda #<argv
|
||||
ldx #>argv
|
||||
sta __argv
|
||||
stx __argv + 1
|
||||
rts
|
||||
|
||||
; These arrays are zeroed before initmainargs is called.
|
||||
; char name[16+1];
|
||||
; char name[16+1];
|
||||
; char* argv[MAXARGS+1]={name};
|
||||
;
|
||||
.bss
|
||||
term: .res 1
|
||||
name: .res NAME_LEN + 1
|
||||
term: .res 1
|
||||
name: .res NAME_LEN + 1
|
||||
|
||||
.data
|
||||
argv: .addr name
|
||||
.res MAXARGS * 2
|
||||
.res MAXARGS * 2
|
||||
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
; /* Initialize the random number generator */
|
||||
;
|
||||
|
||||
.export __randomize
|
||||
.import _srand
|
||||
.export __randomize
|
||||
.import _srand
|
||||
|
||||
.include "vic20.inc"
|
||||
.include "vic20.inc"
|
||||
|
||||
__randomize:
|
||||
lda VIC_LINES ; Get overflow bit
|
||||
|
||||
@@ -4,24 +4,24 @@
|
||||
; unsigned char revers (unsigned char onoff);
|
||||
;
|
||||
|
||||
.export _revers
|
||||
.export _revers
|
||||
|
||||
.include "vic20.inc"
|
||||
|
||||
.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
|
||||
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
; Oliver Schmidt, 2012-09-30
|
||||
;
|
||||
|
||||
.exportzp ST := $90 ; IEC status byte
|
||||
.exportzp ST := $90 ; IEC status byte
|
||||
|
||||
Reference in New Issue
Block a user