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

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

View File

@@ -4,16 +4,16 @@
; Screen size variables
;
.export screensize
.export screensize
.include "pet.inc"
.include "pet.inc"
.proc screensize
ldx SCR_LINELEN
inx ; Variable is one less
ldy #25
rts
ldx SCR_LINELEN
inx ; Variable is one less
ldy #25
rts
.endproc

View File

@@ -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 "pet.inc"
.include "pet.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

View File

@@ -4,65 +4,65 @@
; char cgetc (void);
;
.export _cgetc
.import cursor
.export _cgetc
.import cursor
.include "pet.inc"
.include "pet.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
; Fetch the character from the keyboard buffer
L3: sei
ldy KEY_BUF
ldx #$00
L4: lda KEY_BUF+1,x
sta KEY_BUF,x
inx
cpx KEY_COUNT
bne L4
dec KEY_COUNT
cli
ldx #$00 ; Clear high byte
tya
rts
L3: sei
ldy KEY_BUF
ldx #$00
L4: lda KEY_BUF+1,x
sta KEY_BUF,x
inx
cpx KEY_COUNT
bne L4
dec KEY_COUNT
cli
ldx #$00 ; Clear high byte
tya
rts
; Switch the cursor on or off
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
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
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

View File

@@ -4,46 +4,46 @@
; void clrscr (void);
;
.export _clrscr
.import plot
.importzp ptr1
.export _clrscr
.import plot
.importzp ptr1
.include "pet.inc"
.include "pet.inc"
_clrscr:
; Set the screen base address
lda #$00
sta ptr1
lda #$80
sta ptr1+1
lda #$00
sta ptr1
lda #$80
sta ptr1+1
; Determine, how many pages to fill
ldx #4
lda SCR_LINELEN ; Check length of one line
cmp #40+1
bcc L1
ldx #8
ldx #4
lda SCR_LINELEN ; Check length of one line
cmp #40+1
bcc L1
ldx #8
; Clear the screen
L1: lda #$20 ; Screen code for blank
ldy #$00
L2: sta (ptr1),y
iny
bne L2
inc ptr1+1
dex
bne L2
L1: lda #$20 ; Screen code for blank
ldy #$00
L2: sta (ptr1),y
iny
bne L2
inc ptr1+1
dex
bne L2
; Set the cursor to 0/0
lda #0
sta CURS_X
sta CURS_Y
jmp plot
lda #0
sta CURS_X
sta CURS_Y
jmp plot
rts
rts

View File

@@ -6,13 +6,13 @@
; unsigned char __fastcall__ bordercolor (unsigned char color);
;
.export _textcolor, _bgcolor, _bordercolor
.import return0, return1
.export _textcolor, _bgcolor, _bordercolor
.import return0, return1
_textcolor = return1
_textcolor = return1
_bgcolor = return0
_bgcolor = return0
_bordercolor = return0
_bordercolor = return0

View File

@@ -4,7 +4,7 @@
; Low level stuff for screen output/console input
;
.exportzp CURS_X, CURS_Y
.exportzp CURS_X, CURS_Y
.include "pet.inc"
.include "pet.inc"

View File

@@ -5,43 +5,43 @@
; 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
.include "pet.inc"
.include "pet.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
@@ -55,64 +55,64 @@ L3: iny
rts
newline:
lda SCR_LINELEN ; xsize-1
lda SCR_LINELEN ; xsize-1
sec ; Account for -1 above
adc SCREEN_PTR
sta SCREEN_PTR
bcc L4
inc SCREEN_PTR+1
L4: inc CURS_Y
rts
adc SCREEN_PTR
sta SCREEN_PTR
bcc L4
inc SCREEN_PTR+1
L4: inc CURS_Y
rts
; Handle character if high bit set
L10: and #$7F
cmp #$7E ; PI?
bne L11
lda #$5E ; Load screen code for PI
bne cputdirect
L11: ora #$40
bne cputdirect
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_Y
lda ScrLo,y
sta SCREEN_PTR
lda ScrHi,y
ldy SCR_LINELEN
cpy #40+1
bcc @L1
asl SCREEN_PTR ; 80 column mode
rol a
@L1: ora #$80 ; Screen at $8000
sta SCREEN_PTR+1
rts
plot: ldy CURS_Y
lda ScrLo,y
sta SCREEN_PTR
lda ScrHi,y
ldy SCR_LINELEN
cpy #40+1
bcc @L1
asl SCREEN_PTR ; 80 column mode
rol a
@L1: ora #$80 ; Screen at $8000
sta SCREEN_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
rts
ora RVS ; Set revers bit
ldy CURS_X
sta (SCREEN_PTR),y ; Set char
rts
; Screen address tables - offset to real screen
.rodata
ScrLo: .byte $00, $28, $50, $78, $A0, $C8, $F0, $18
.byte $40, $68, $90, $B8, $E0, $08, $30, $58
.byte $80, $A8, $D0, $F8, $20, $48, $70, $98
.byte $C0
ScrLo: .byte $00, $28, $50, $78, $A0, $C8, $F0, $18
.byte $40, $68, $90, $B8, $E0, $08, $30, $58
.byte $80, $A8, $D0, $F8, $20, $48, $70, $98
.byte $C0
ScrHi: .byte $00, $00, $00, $00, $00, $00, $00, $01
.byte $01, $01, $01, $01, $01, $02, $02, $02
.byte $02, $02, $02, $02, $03, $03, $03, $03
.byte $03
ScrHi: .byte $00, $00, $00, $00, $00, $00, $00, $01
.byte $01, $01, $01, $01, $01, $02, $02, $02
.byte $02, $02, $02, $02, $03, $03, $03, $03
.byte $03

View File

@@ -2,32 +2,32 @@
; Startup code for cc65 (PET version)
;
.export _exit
.export __STARTUP__ : absolute = 1 ; Mark as startup
.import initlib, donelib
.import zerobss, push0
.import callmain
.import CLRCH, BSOUT
.importzp ST
.export _exit
.export __STARTUP__ : absolute = 1 ; Mark as startup
.import initlib, donelib
.import zerobss, push0
.import callmain
.import CLRCH, BSOUT
.importzp ST
.include "zeropage.inc"
.include "pet.inc"
.include "../cbm/cbm.inc"
.include "zeropage.inc"
.include "pet.inc"
.include "../cbm/cbm.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. The routine that is called by BSOUT to switch the
; character set will use FNLEN as temporary storage - YUCK! Since the
@@ -35,72 +35,72 @@ L1: lda sp,x
; information, we need to save and restore it here.
; Thanks to Stefan Haubenthal for this information!
lda FNLEN
pha ; Save FNLEN
lda #14
; sta $E84C ; See PET FAQ
jsr BSOUT
pla
sta FNLEN ; Restore FNLEN
lda FNLEN
pha ; Save FNLEN
lda #14
; sta $E84C ; See PET FAQ
jsr BSOUT
pla
sta FNLEN ; Restore FNLEN
; 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 MEMSIZE
sta sp
lda MEMSIZE+1
sta sp+1 ; Set argument stack ptr
lda MEMSIZE
sta sp
lda MEMSIZE+1
sta sp+1 ; Set argument stack ptr
; 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.
_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
; Store the program return code into ST
pla
sta ST
pla
sta ST
; Restore the stack pointer
ldx spsave
txs ; Restore stack pointer
ldx spsave
txs ; Restore stack pointer
; Back to basic
rts
rts
; ------------------------------------------------------------------------
.segment "ZPSAVE"
.segment "ZPSAVE"
zpsave: .res zpspace
zpsave: .res zpspace
; ------------------------------------------------------------------------
.bss
spsave: .res 1
mmusave:.res 1
spsave: .res 1
mmusave:.res 1

View File

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

View File

@@ -6,7 +6,7 @@
;
.include "pet.inc"
.include "get_tv.inc"
.include "get_tv.inc"
;--------------------------------------------------------------------------
; _get_tv

View File

@@ -2,48 +2,48 @@
; IRQ handling (PET version)
;
.export initirq, doneirq
.import callirq
.export initirq, doneirq
.import callirq
.include "pet.inc"
.include "pet.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

View File

@@ -6,47 +6,47 @@
; obviously based on Ullrichs driver :)
;
.include "zeropage.inc"
.include "zeropage.inc"
.include "joy-kernel.inc"
.include "joy-error.inc"
; .include "pet.inc"
VIA_PRA := $E841 ; Port register A
VIA_DDRA := $E843 ; Data direction register A
.include "joy-kernel.inc"
.include "joy-error.inc"
; .include "pet.inc"
VIA_PRA := $E841 ; Port register A
VIA_DDRA := $E843 ; Data direction register A
; ------------------------------------------------------------------------
; 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
JOY_COUNT = 2 ; Number of joysticks we support
JOY_COUNT = 2 ; Number of joysticks we support
.code
@@ -59,9 +59,9 @@ JOY_COUNT = 2 ; 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,44 +77,44 @@ 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: lda #%10000000 ; via port A Data-Direction
sta VIA_DDRA ; bit 7: out bit 6-0: in
READ: lda #%10000000 ; via port A Data-Direction
sta VIA_DDRA ; bit 7: out bit 6-0: in
tax ; Joystick number into X
bne joy2
tax ; Joystick number into X
bne joy2
; Read joystick 1
joy1: lda #$80 ; via port A read/write
sta VIA_PRA ; (output one at PA7)
joy1: lda #$80 ; via port A read/write
sta VIA_PRA ; (output one at PA7)
lda VIA_PRA ; via port A read/write
and #$1f ; get bit 4-0 (PA4-PA0)
eor #$1f
rts
lda VIA_PRA ; via port A read/write
and #$1f ; get bit 4-0 (PA4-PA0)
eor #$1f
rts
; Read joystick 2
joy2: lda #$00 ; via port A read/write
sta VIA_PRA ; (output zero at PA7)
joy2: lda #$00 ; via port A read/write
sta VIA_PRA ; (output zero at PA7)
lda VIA_PRA ; via port A read/write
and #$0f ; get bit 3-0 (PA3-PA0)
sta tmp1 ; joy 4 directions
lda VIA_PRA ; via port A read/write
and #$0f ; get bit 3-0 (PA3-PA0)
sta tmp1 ; joy 4 directions
lda VIA_PRA ; via port A read/write
and #%00100000 ; get bit 5 (PA5)
lsr
ora tmp1
eor #$1f
lda VIA_PRA ; via port A read/write
and #%00100000 ; get bit 5 (PA5)
lsr
ora tmp1
eor #$1f
ldx #0
rts
ldx #0
rts

View File

@@ -4,46 +4,46 @@
; Marco van den Heuvel, 2010-01-23
;
.include "zeropage.inc"
.include "zeropage.inc"
.include "joy-kernel.inc"
.include "joy-error.inc"
.include "pet.inc"
.include "joy-kernel.inc"
.include "joy-error.inc"
.include "pet.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
JOY_COUNT = 2 ; Number of joysticks we support
JOY_COUNT = 2 ; Number of joysticks we support
.code
@@ -56,9 +56,9 @@ JOY_COUNT = 2 ; 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.
@@ -66,7 +66,7 @@ INSTALL:
;
UNINSTALL:
rts
rts
; ------------------------------------------------------------------------
@@ -74,52 +74,52 @@ 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
tax ; Joystick number into X
bne joy2
; Read joystick 1
joy1:
lda #0
sta VIA_DDRA
lda VIA_PRA
and #$0f
cmp #$0c
bne @notc1
lda #$0f
bne @end1
lda #0
sta VIA_DDRA
lda VIA_PRA
and #$0f
cmp #$0c
bne @notc1
lda #$0f
bne @end1
@notc1:
ora #$10
ora #$10
@end1:
eor #$1f
rts
eor #$1f
rts
; Read joystick 2
joy2:
lda #0
sta VIA_DDRA
lda VIA_PRA
lsr
lsr
lsr
lsr
cmp #$0c
bne @notc2
lda #$0f
bne @end2
lda #0
sta VIA_DDRA
lda VIA_PRA
lsr
lsr
lsr
lsr
cmp #$0c
bne @notc2
lda #$0f
bne @end2
@notc2:
ora #$10
ora #$10
@end2:
eor #$1f
ldx #0
rts
eor #$1f
ldx #0
rts

View File

@@ -6,8 +6,8 @@
; const void joy_static_stddrv[];
;
.export _joy_static_stddrv
.import _pet_stdjoy_joy
.export _joy_static_stddrv
.import _pet_stdjoy_joy
.rodata

View File

@@ -6,9 +6,9 @@
; const char joy_stddrv[];
;
.export _joy_stddrv
.export _joy_stddrv
.rodata
_joy_stddrv: .asciiz "pet-stdjoy.joy"
_joy_stddrv: .asciiz "pet-stdjoy.joy"

View File

@@ -4,15 +4,15 @@
; unsigned char kbhit (void);
;
.export _kbhit
.export _kbhit
.include "pet.inc"
.include "pet.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

View File

@@ -19,10 +19,10 @@
;-----------------------------------------------------------------------------
; Functions that are available in the kernal jump table
CLRCH = $FFCC
BASIN = $FFCF
STOP = $FFE1
GETIN = $FFE4
CLALL = $FFE7
UDTIM = $FFEA
CLRCH = $FFCC
BASIN = $FFCF
STOP = $FFE1
GETIN = $FFE4
CLALL = $FFE7
UDTIM = $FFEA

View File

@@ -5,14 +5,14 @@
; Setup arguments for main
;
.constructor initmainargs, 24
.import __argc, __argv
.constructor initmainargs, 24
.import __argc, __argv
.include "pet.inc"
.include "pet.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
BASIC_BUF= $200
@@ -20,106 +20,106 @@ BASIC_BUF= $200
; Get possible command-line arguments. Goes into the special INIT segment,
; which may be reused after the startup code is run
.segment "INIT"
.segment "INIT"
.proc initmainargs
.proc initmainargs
; Assume that the program was loaded, a moment ago, by the traditional LOAD
; statement. Save the "most-recent filename" as argument #0.
; Because the buffer, that we're copying into, was zeroed out,
; we don't need to add a NUL character.
;
ldy FNLEN
cpy #NAME_LEN + 1
bcc L1
ldy #NAME_LEN - 1 ; limit the length
L0: lda (FNADR),y
sta name,y
L1: dey
bpl L0
inc __argc ; argc always is equal to, at least, 1
ldy FNLEN
cpy #NAME_LEN + 1
bcc L1
ldy #NAME_LEN - 1 ; limit the length
L0: lda (FNADR),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
next: lda BASIC_BUF,x
beq done ; End of line reached
inx
cmp #' ' ; Skip leading spaces
beq next ;
next: lda BASIC_BUF,x
beq done ; End of line reached
inx
cmp #' ' ; Skip leading spaces
beq next ;
; Found start of next argument. We've incremented the pointer in X already, so
; it points to the second character of the argument. This is useful since we
; will check now for a quoted argument, in which case we will have to skip this
; first character.
found: cmp #'"' ; Is the argument quoted?
beq setterm ; Jump if so
dex ; Reset pointer to first argument character
lda #' ' ; A space ends the argument
setterm:sta term ; Set end of argument marker
found: cmp #'"' ; Is the argument quoted?
beq setterm ; Jump if so
dex ; Reset pointer to first argument character
lda #' ' ; A space ends the argument
setterm:sta term ; Set end of argument marker
; Now store a pointer to the argument into the next slot. Since the BASIC
; input buffer is located at the start of a RAM page, no calculations are
; necessary.
txa ; Get low byte
sta argv,y ; argv[y]= &arg
iny
lda #>BASIC_BUF
sta argv,y
iny
inc __argc ; Found another arg
txa ; Get low byte
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
argloop:lda BASIC_BUF,x
beq done
inx
cmp term
bne argloop
argloop:lda BASIC_BUF,x
beq done
inx
cmp term
bne argloop
; We've found the end of the argument. X points one character behind it, and
; A contains the terminating character. To make the argument a valid C string,
; replace the terminating character by a zero.
lda #0
sta BASIC_BUF-1,x
lda #0
sta BASIC_BUF-1,x
; Check if the maximum number of command line arguments is reached. If not,
; parse the next one.
lda __argc ; Get low byte of argument count
cmp #MAXARGS ; Maximum number of arguments reached?
bcc next ; Parse next one if not
lda __argc ; Get low byte of argument count
cmp #MAXARGS ; Maximum number of arguments reached?
bcc next ; Parse next one if not
; (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
.endproc
; 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
argv: .addr name
.res MAXARGS * 2

View File

@@ -5,10 +5,10 @@
; /* Initialize the random number generator */
;
.export __randomize
.import _srand
.export __randomize
.import _srand
.include "pet.inc"
.include "pet.inc"
__randomize:
ldx TIME

View File

@@ -4,24 +4,24 @@
; unsigned char revers (unsigned char onoff);
;
.export _revers
.export _revers
.include "pet.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

View File

@@ -2,4 +2,4 @@
; Oliver Schmidt, 2012-09-30
;
.exportzp ST := $96 ; IEC status byte
.exportzp ST := $96 ; IEC status byte