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

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

View File

@@ -4,7 +4,7 @@
; Screen size variables
;
.export screensize
.export screensize
; We will return the values directly instead of banking in the ROM and calling
; SCREEN which is a lot more overhead in code size and CPU cycles.

View File

@@ -5,46 +5,46 @@
; void reset_brk (void);
;
.export _set_brk, _reset_brk
.export _brk_a, _brk_x, _brk_y, _brk_sr, _brk_pc
.export _set_brk, _reset_brk
.export _brk_a, _brk_x, _brk_y, _brk_sr, _brk_pc
.import brk_jmp
.include "plus4.inc"
.include "plus4.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 #<brk_handler ; Set the break vector to our routine
sta brk_jmp+1
lda #>brk_handler
sta brk_jmp+2
rts
lda #<brk_handler ; Set the break vector to our routine
sta brk_jmp+1
lda #>brk_handler
sta brk_jmp+2
rts
.endproc
; Reset the break vector
.proc _reset_brk
.proc _reset_brk
lda #$00
sta brk_jmp+1
@@ -57,37 +57,37 @@ uservec: jmp $FFFF ; Patched at runtime
; 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,87 +4,87 @@
; char cgetc (void);
;
.export _cgetc
.import cursor
.export _cgetc
.import cursor
.include "plus4.inc"
.include "plus4.inc"
; --------------------------------------------------------------------------
.segment "LOWCODE" ; Accesses the ROM - must go into low mem
_cgetc: lda KEY_COUNT ; Get number of characters
ora FKEY_COUNT ; Or with number of function key chars
bne L2 ; Jump if there are already chars waiting
_cgetc: lda KEY_COUNT ; Get number of characters
ora FKEY_COUNT ; Or with number of function key chars
bne L2 ; Jump if there are already chars waiting
; Switch on the cursor if needed
ldy CURS_X
lda (CRAM_PTR),y ; Get current char
pha ; And save it
lda CHARCOLOR
sta (CRAM_PTR),y
ldy CURS_X
lda (CRAM_PTR),y ; Get current char
pha ; And save it
lda CHARCOLOR
sta (CRAM_PTR),y
lda cursor
beq L1 ; Jump if no cursor
tya
clc
adc SCREEN_PTR
sta TED_CURSLO
lda SCREEN_PTR+1
adc #$00
sbc #$0B ; + carry = $C00 (screen address)
sta TED_CURSHI
lda cursor
beq L1 ; Jump if no cursor
tya
clc
adc SCREEN_PTR
sta TED_CURSLO
lda SCREEN_PTR+1
adc #$00
sbc #$0B ; + carry = $C00 (screen address)
sta TED_CURSHI
L1: lda KEY_COUNT
ora FKEY_COUNT
beq L1
pla
sta (CRAM_PTR),y
lda #$ff
sta TED_CURSLO ; Cursor off
sta TED_CURSHI
L1: lda KEY_COUNT
ora FKEY_COUNT
beq L1
pla
sta (CRAM_PTR),y
lda #$ff
sta TED_CURSLO ; Cursor off
sta TED_CURSHI
L2: sta ENABLE_ROM ; Bank in the ROM
jsr KBDREAD ; Read char and return in A (ROM routine)
L2: sta ENABLE_ROM ; Bank in the ROM
jsr KBDREAD ; Read char and return in A (ROM routine)
sta ENABLE_RAM ; Reenable the RAM
ldx #0
rts
ldx #0
rts
; --------------------------------------------------------------------------
; Make the function keys return function key codes instead of the current
; strings so the program will see and may handle them.
; Undo this change when the program ends
.constructor initkbd
.destructor donekbd
.constructor initkbd
.destructor donekbd
.segment "INIT" ; Special init code segment may get overwritten
.proc initkbd
.proc initkbd
ldy #15
@L1: lda fnkeys,y
sta FKEY_SPACE,y
dey
bpl @L1
rts
ldy #15
@L1: lda fnkeys,y
sta FKEY_SPACE,y
dey
bpl @L1
rts
.endproc
.segment "LOWCODE" ; Accesses the ROM - must go into low mem
.proc donekbd
.proc donekbd
ldx #$39 ; Copy the original function keys
ldx #$39 ; Copy the original function keys
sta ENABLE_ROM ; Bank in the ROM
@L1: lda FKEY_ORIG,x
sta FKEY_SPACE,x
dex
bpl @L1
@L1: lda FKEY_ORIG,x
sta FKEY_SPACE,x
dex
bpl @L1
sta ENABLE_RAM ; Bank out the ROM
rts
rts
.endproc
@@ -92,6 +92,6 @@ L2: sta ENABLE_ROM ; Bank in the ROM
; Function key table, readonly
.rodata
fnkeys: .byte $01, $01, $01, $01, $01, $01, $01, $01
.byte 133, 137, 134, 138, 135, 139, 136, 140
fnkeys: .byte $01, $01, $01, $01, $01, $01, $01, $01
.byte 133, 137, 134, 138, 135, 139, 136, 140

View File

@@ -4,9 +4,9 @@
; void clrscr (void);
;
.export _clrscr
.export _clrscr
.include "plus4.inc"
.include "plus4.inc"
.segment "LOWCODE" ; Must go into low memory

View File

@@ -6,28 +6,28 @@
; unsigned char __fastcall__ bordercolor (unsigned char color);
;
.export _textcolor, _bgcolor, _bordercolor
.export _textcolor, _bgcolor, _bordercolor
.include "plus4.inc"
.include "plus4.inc"
_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:
ldx TED_BGCOLOR ; get old value
sta TED_BGCOLOR ; set new value
txa
rts
ldx TED_BGCOLOR ; get old value
sta TED_BGCOLOR ; set new value
txa
rts
_bordercolor:
ldx TED_BORDERCOLOR ; get old value
sta TED_BORDERCOLOR ; set new value
txa
rts
ldx TED_BORDERCOLOR ; get old value
sta TED_BORDERCOLOR ; set new value
txa
rts

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

View File

@@ -5,45 +5,45 @@
; 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 "plus4.inc"
.include "plus4.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
@@ -57,39 +57,39 @@ 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

View File

@@ -2,30 +2,30 @@
; Startup code for cc65 (Plus/4 version)
;
.export _exit
.export _exit
.export brk_jmp
.export __STARTUP__ : absolute = 1 ; Mark as startup
.import callirq_y, initlib, donelib
.import callmain, zerobss
.import __INTERRUPTOR_COUNT__
.import __RAM_START__, __RAM_SIZE__ ; Linker generated
.import __STACKSIZE__ ; Linker generated
.importzp ST
.import callirq_y, initlib, donelib
.import callmain, zerobss
.import __INTERRUPTOR_COUNT__
.import __RAM_START__, __RAM_SIZE__ ; Linker generated
.import __STACKSIZE__ ; Linker generated
.importzp ST
.include "zeropage.inc"
.include "plus4.inc"
.include "plus4.inc"
; ------------------------------------------------------------------------
; Constants
IRQInd = $500 ; JMP $0000 - used as indirect IRQ vector
IRQInd = $500 ; JMP $0000 - used as indirect IRQ vector
; ------------------------------------------------------------------------
; Startup code
.segment "STARTUP"
.segment "STARTUP"
Start:
@@ -33,24 +33,24 @@ Start:
sei ; No interrupts since we're banking out the ROM
sta ENABLE_RAM
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
sta ENABLE_ROM
cli
; Switch to second charset
lda #14
jsr $FFD2 ; BSOUT
lda #14
jsr $FFD2 ; BSOUT
; Save system stuff and setup the stack. The stack starts at the top of the
; usable RAM.
tsx
stx spsave ; save system stk ptr
tsx
stx spsave ; save system stk ptr
lda #<(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
sta sp
@@ -69,7 +69,7 @@ L1: lda sp,x
; Clear the BSS data
jsr zerobss
jsr zerobss
; Initialize irqcount, which means that from now own custom linked in IRQ
; handlers (via condes) will be called.
@@ -79,44 +79,44 @@ L1: lda sp,x
; 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
jsr donelib ; Run module destructors
_exit: pha ; Save the return code
jsr donelib ; Run module destructors
; Disable chained IRQ handlers
lda #0
lda #0
sta irqcount ; Disable custom IRQ handlers
; 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
; Enable the ROM and return to BASIC
sta ENABLE_ROM
rts
rts
; ------------------------------------------------------------------------
; IRQ handler. The handler in the ROM enables the kernal and jumps to
@@ -128,12 +128,12 @@ L2: lda zpsave,x
.segment "LOWCODE"
IRQ: cld ; Just to be sure
pha
IRQ: cld ; Just to be sure
pha
txa
pha
tya
pha
tya
pha
tsx ; Get the stack pointer
lda $0104,x ; Get the saved status register
and #$10 ; Test for BRK bit
@@ -144,8 +144,8 @@ IRQ: cld ; Just to be sure
; condes function is not reentrant. The irqcount flag will be set/reset from
; the main code, to avoid races.
ldy irqcount
beq @L1
ldy irqcount
beq @L1
jsr callirq_y ; Call the IRQ functions
; Since the ROM handler will end with an RTI, we have to fake an IRQ return
@@ -156,17 +156,17 @@ IRQ: cld ; Just to be sure
pha
lda #<irq_ret
pha
php ; Push faked IRQ frame on stack
pha ; Push faked A register
pha ; Push faked X register
pha ; Push faked Y register
php ; Push faked IRQ frame on stack
pha ; Push faked A register
pha ; Push faked X register
pha ; Push faked Y register
sta ENABLE_ROM ; Switch to ROM
jmp (IRQVec) ; Jump indirect to kernal irq handler
irq_ret:
sta ENABLE_RAM ; Switch back to RAM
pla
tay
pla
tay
pla
tax
pla
@@ -191,12 +191,12 @@ nohandler:
; BRK handling
brk_jmp: jmp $0000
spsave: .res 1
spsave: .res 1
irqcount: .byte 0
.segment "ZPSAVE"
zpsave: .res zpspace
zpsave: .res zpspace

View File

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

View File

@@ -6,7 +6,7 @@
;
.include "plus4.inc"
.include "get_tv.inc"
.include "get_tv.inc"
;--------------------------------------------------------------------------
@@ -14,7 +14,7 @@
.proc _get_tv
ldx #TV::PAL ; Assume PAL
ldx #TV::PAL ; Assume PAL
bit TED_MULTI1 ; Test bit 6
bvc pal
dex ; NTSC

View File

@@ -2,8 +2,8 @@
; IRQ handling (Plus/4 version)
;
.export initirq, doneirq
.export initirq, doneirq
initirq:
doneirq:
rts
rts

View File

@@ -5,9 +5,9 @@
; Ullrich von Bassewitz, 2002-12-21
;
.include "zeropage.inc"
.include "zeropage.inc"
.include "joy-kernel.inc"
.include "joy-kernel.inc"
.include "joy-error.inc"
.include "plus4.inc"
@@ -21,8 +21,8 @@
; 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)
@@ -65,7 +65,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.
@@ -89,16 +89,16 @@ COUNT:
; READ: Read a particular joystick passed in A.
;
READ: ldy #$FA ; Load index for joystick #1
tax ; Test joystick number
beq @L1
ldy #$FB ; Load index for joystick #2
READ: ldy #$FA ; Load index for joystick #1
tax ; Test joystick number
beq @L1
ldy #$FB ; Load index for joystick #2
@L1: sei
sty TED_KBD
lda TED_KBD
cli
ldx #$00 ; Clear high byte
and #$1F
eor #$1F
rts
sty TED_KBD
lda TED_KBD
cli
ldx #$00 ; Clear high byte
and #$1F
eor #$1F
rts

View File

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

View File

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

View File

@@ -4,16 +4,16 @@
; unsigned char kbhit (void);
;
.export _kbhit
.export _kbhit
.include "plus4.inc"
.include "plus4.inc"
.proc _kbhit
ldx #0 ; High byte of return is always zero
lda KEY_COUNT ; Get number of characters
ora FKEY_COUNT ; Or with number of chars from function keys
lda KEY_COUNT ; Get number of characters
ora FKEY_COUNT ; Or with number of chars from function keys
beq L9
lda #1
L9: rts

View File

@@ -12,7 +12,7 @@
.proc CLOSE
sta ENABLE_ROM ; Enable the ROM
clc ; Force C64 compatible behaviour
clc ; Force C64 compatible behaviour
jsr $FFC3 ; Call the ROM routine
sta ENABLE_RAM ; Switch back to RAM
rts ; Return to caller

View File

@@ -17,7 +17,7 @@
; Store the length of the name into the zero page
sta FNAM_LEN
sta FNAM_LEN
; Check if we have to copy the name to low memory

View File

@@ -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 "plus4.inc"
.include "plus4.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,22 +120,22 @@ 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

View File

@@ -5,10 +5,10 @@
; /* Initialize the random number generator */
;
.export __randomize
.import _srand
.export __randomize
.import _srand
.include "plus4.inc"
.include "plus4.inc"
__randomize:
ldx TED_VLINELO ; Use TED rasterline as high byte

View File

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

@@ -24,7 +24,7 @@
.include "zeropage.inc"
.include "ser-kernel.inc"
.include "ser-error.inc"
.include "plus4.inc"
.include "plus4.inc"
; ------------------------------------------------------------------------
@@ -47,12 +47,12 @@
.word PUT
.word STATUS
.word IOCTL
.word IRQ
.word IRQ
;----------------------------------------------------------------------------
; I/O definitions
ACIA = $DE00
ACIA = $DE00
ACIA_DATA = ACIA+0 ; Data register
ACIA_STATUS = ACIA+1 ; Status register
ACIA_CMD = ACIA+2 ; Command register
@@ -64,19 +64,19 @@ ACIA_CTRL = ACIA+3 ; Control register
;
.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
@@ -146,14 +146,14 @@ CLOSE:
; Deactivate DTR and disable 6551 interrupts
lda #%00001010
sta ACIA_CMD
lda #%00001010
sta ACIA_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.
@@ -163,22 +163,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.
@@ -187,48 +187,48 @@ 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
sta ACIA_CTRL
ora #%00010000 ; Receiver clock source = baudrate
sta ACIA_CTRL
; 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
sta ACIA_CMD
ora #%00000001 ; DTR active
sta RtsOff
ora #%00001000 ; Enable receive interrupts
sta ACIA_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
@@ -243,43 +243,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 ; (25)
cmp #$ff
bne @L2
lda #<SER_ERR_NO_DATA
ldx #>SER_ERR_NO_DATA
rts
@L1: lda RecvFreeCnt ; (25)
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 ; (34)
beq @L3
cmp #63
bcc @L3
lda #$00
sta Stopped
lda RtsOff
ora #%00001000
sta ACIA_CMD
@L2: ldx Stopped ; (34)
beq @L3
cmp #63
bcc @L3
lda #$00
sta Stopped
lda RtsOff
ora #%00001000
sta ACIA_CMD
; Get byte from buffer
@L3: ldx RecvHead ; (41)
lda RecvBuf,x
inc RecvHead
inc RecvFreeCnt
ldx #$00 ; (59)
sta (ptr1,x)
txa ; Return code = 0
rts
@L3: ldx RecvHead ; (41)
lda RecvBuf,x
inc RecvHead
inc RecvFreeCnt
ldx #$00 ; (59)
sta (ptr1,x)
txa ; Return code = 0
rts
;----------------------------------------------------------------------------
; PUT: Output character in A.
@@ -290,40 +290,40 @@ 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.
; Must return an error code in a/x.
;
STATUS: lda ACIA_STATUS
ldx #0
sta (ptr1,x)
txa ; SER_ERR_OK
STATUS: lda ACIA_STATUS
ldx #0
sta (ptr1,x)
txa ; SER_ERR_OK
rts
;----------------------------------------------------------------------------
@@ -334,7 +334,7 @@ STATUS: lda ACIA_STATUS
IOCTL: lda #<SER_ERR_INV_IOCTL ; We don't support ioclts for now
ldx #>SER_ERR_INV_IOCTL
rts ; Run into IRQ instead
rts ; Run into IRQ instead
;----------------------------------------------------------------------------
; IRQ: Called from the builtin runtime IRQ handler as a subroutine. All
@@ -343,25 +343,25 @@ IOCTL: lda #<SER_ERR_INV_IOCTL ; We don't support ioclts for now
; was handled, otherwise with carry clear.
;
IRQ: lda ACIA_STATUS ; Check ACIA status for receive interrupt
and #$08
beq @L9 ; Jump if no ACIA interrupt (carry still clear)
lda ACIA_DATA ; 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
bcc @L1 ; Assert flow control if buffer space low
IRQ: lda ACIA_STATUS ; Check ACIA status for receive interrupt
and #$08
beq @L9 ; Jump if no ACIA interrupt (carry still clear)
lda ACIA_DATA ; 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
bcc @L1 ; Assert flow control if buffer space low
rts ; Return with carry set (interrupt handled)
; Assert flow control if buffer space too low
@L1: lda RtsOff
sta ACIA_CMD
sta Stopped
@L1: lda RtsOff
sta ACIA_CMD
sta Stopped
sec ; Interrupt handled
@L9: rts
@@ -370,33 +370,33 @@ IRQ: lda ACIA_STATUS ; Check ACIA status for receive interrupt
.proc TryToSend
sta tmp1 ; Remember tryHard flag
@L0: lda SendFreeCnt
cmp #$ff
beq @L3 ; Bail out
sta tmp1 ; Remember tryHard flag
@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: lda ACIA_STATUS
and #$10
bne @L4
bit tmp1 ;keep trying if must try hard
bmi @L0
@L3: rts
@L2: lda ACIA_STATUS
and #$10
bne @L4
bit tmp1 ;keep trying if must try hard
bmi @L0
@L3: rts
; Send byte and try again
@L4: ldx SendHead
lda SendBuf,x
sta ACIA_DATA
inc SendHead
inc SendFreeCnt
jmp @L0
@L4: ldx SendHead
lda SendBuf,x
sta ACIA_DATA
inc SendHead
inc SendFreeCnt
jmp @L0
.endproc

View File

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

View File

@@ -9,7 +9,7 @@
; */
;
.export __systime
.export __systime
.importzp sreg