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

@@ -3,17 +3,17 @@
;
; This header is required for BLL builds.
;
.import __BSS_LOAD__
.import __RAM_START__
.export __BLLHDR__: absolute = 1
.import __BSS_LOAD__
.import __RAM_START__
.export __BLLHDR__: absolute = 1
; ------------------------------------------------------------------------
; BLL header (BLL header)
.segment "BLLHDR"
.word $0880
.dbyt __RAM_START__
.dbyt __BSS_LOAD__ - __RAM_START__ + 10
.byte $42,$53
.byte $39,$33
.segment "BLLHDR"
.word $0880
.dbyt __RAM_START__
.dbyt __BSS_LOAD__ - __RAM_START__ + 10
.byte $42,$53
.byte $39,$33

View File

@@ -3,177 +3,177 @@
;
; This bootloader creates a signed binary so that the Lynx will accept it.
;
.include "lynx.inc"
.include "extzp.inc"
.import __BLOCKSIZE__
.export __BOOTLDR__: absolute = 1
.include "lynx.inc"
.include "extzp.inc"
.import __BLOCKSIZE__
.export __BOOTLDR__: absolute = 1
; ------------------------------------------------------------------------
; Bootloader
.segment "BOOTLDR"
.segment "BOOTLDR"
;**********************************
; Here is the bootloader in plaintext
; The idea is to make the smalles possible encrypted loader as decryption
; is very slow. The minimum size is 49 bytes plus a zero byte.
;**********************************
; EXE = $fb68
; EXE = $fb68
;
; .org $0200
; .org $0200
;
; ; 1. force Mikey to be in memory
; stz MAPCTL
; ; 1. force Mikey to be in memory
; stz MAPCTL
;
; ; 3. set ComLynx to open collector
; lda #4 ; a = 00000100
; sta SERCTL ; set the ComLynx to open collector
; ; 3. set ComLynx to open collector
; lda #4 ; a = 00000100
; sta SERCTL ; set the ComLynx to open collector
;
; ; 4. make sure the ROM is powered on
; lda #8 ; a = 00001000
; sta IODAT ; set the ROM power to on
; ; 4. make sure the ROM is powered on
; lda #8 ; a = 00001000
; sta IODAT ; set the ROM power to on
;
; ; 5. read in secondary exe + 8 bytes from the cart and store it in $f000
; ldx #0 ; x = 0
; ldy #$97 ; y = secondary loader size (151 bytes)
; ; 5. read in secondary exe + 8 bytes from the cart and store it in $f000
; ldx #0 ; x = 0
; ldy #$97 ; y = secondary loader size (151 bytes)
;rloop1: lda RCART0 ; read a byte from the cart
; sta EXE,X ; EXE[X] = a
; inx ; x++
; dey ; y--
; bne rloop1 ; loops until y wraps
; sta EXE,X ; EXE[X] = a
; inx ; x++
; dey ; y--
; bne rloop1 ; loops until y wraps
;
; ; 6. jump to secondary loader
; jmp EXE ; run the secondary loader
; ; 6. jump to secondary loader
; jmp EXE ; run the secondary loader
;
; .reloc
; .reloc
;**********************************
; After compilation, encryption and obfuscation it turns into this.
;**********************************
.byte $ff, $81, $ca, $33, $be, $80, $a2, $c4
.byte $6d, $98, $fe, $8d, $bc, $66, $c0, $7a
.byte $09, $50, $23, $28, $18, $c8, $06, $70
.byte $58, $4f, $1b, $e1, $c7, $90, $08, $cd
.byte $1a, $6e, $5a, $45, $32, $d7, $6d, $c6
.byte $8a, $e5, $d8, $5c, $a0, $e8, $4f, $7a
.byte $5f, $73, $8d, $22
.byte $ff, $81, $ca, $33, $be, $80, $a2, $c4
.byte $6d, $98, $fe, $8d, $bc, $66, $c0, $7a
.byte $09, $50, $23, $28, $18, $c8, $06, $70
.byte $58, $4f, $1b, $e1, $c7, $90, $08, $cd
.byte $1a, $6e, $5a, $45, $32, $d7, $6d, $c6
.byte $8a, $e5, $d8, $5c, $a0, $e8, $4f, $7a
.byte $5f, $73, $8d, $22
;**********************************
; Now we have the secondary loader
;**********************************
.org $fb68
; 1. Read in the 1st File-entry (main exe) in FileEntry
ldx #$00
ldy #8
rloop: lda RCART0 ; read a byte from the cart
sta _FileEntry,X ; EXE[X] = a
inx
dey
bne rloop
.org $fb68
; 1. Read in the 1st File-entry (main exe) in FileEntry
ldx #$00
ldy #8
rloop: lda RCART0 ; read a byte from the cart
sta _FileEntry,X ; EXE[X] = a
inx
dey
bne rloop
; 2. Set the block hardware to the main exe start
lda _FileStartBlock
sta _FileCurrBlock
jsr seclynxblock
; 2. Set the block hardware to the main exe start
lda _FileStartBlock
sta _FileCurrBlock
jsr seclynxblock
; 3. Skip over the block offset
lda _FileBlockOffset+1
eor #$FF
tay
lda _FileBlockOffset
eor #$FF
tax
jsr seclynxskip0
; 3. Skip over the block offset
lda _FileBlockOffset+1
eor #$FF
tay
lda _FileBlockOffset
eor #$FF
tax
jsr seclynxskip0
; 4. Read in the main exe to RAM
lda _FileDestAddr
ldx _FileDestAddr+1
sta _FileDestPtr
stx _FileDestPtr+1
lda _FileFileLen+1
eor #$FF
tay
lda _FileFileLen
eor #$FF
tax
jsr seclynxread0
; 4. Read in the main exe to RAM
lda _FileDestAddr
ldx _FileDestAddr+1
sta _FileDestPtr
stx _FileDestPtr+1
lda _FileFileLen+1
eor #$FF
tay
lda _FileFileLen
eor #$FF
tax
jsr seclynxread0
; 5. Jump to start of the main exe code
jmp (_FileDestAddr)
; 5. Jump to start of the main exe code
jmp (_FileDestAddr)
;**********************************
; Skip bytes on bank 0
; X:Y count (EOR $FFFF)
;**********************************
seclynxskip0:
inx
bne @0
iny
beq exit
@0: jsr secreadbyte0
bra seclynxskip0
inx
bne @0
iny
beq exit
@0: jsr secreadbyte0
bra seclynxskip0
;**********************************
; Read bytes from bank 0
; X:Y count (EOR $ffff)
;**********************************
seclynxread0:
inx
bne @1
iny
beq exit
@1: jsr secreadbyte0
sta (_FileDestPtr)
inc _FileDestPtr
bne seclynxread0
inc _FileDestPtr+1
bra seclynxread0
inx
bne @1
iny
beq exit
@1: jsr secreadbyte0
sta (_FileDestPtr)
inc _FileDestPtr
bne seclynxread0
inc _FileDestPtr+1
bra seclynxread0
;**********************************
; Read one byte from cartridge
;**********************************
secreadbyte0:
lda RCART0
inc _FileBlockByte
bne exit
inc _FileBlockByte+1
bne exit
lda RCART0
inc _FileBlockByte
bne exit
inc _FileBlockByte+1
bne exit
;**********************************
; Select a block
;**********************************
seclynxblock:
pha
phx
phy
lda __iodat
and #$fc
tay
ora #2
tax
lda _FileCurrBlock
inc _FileCurrBlock
sec
bra @2
@0: bcc @1
stx IODAT
clc
@1: inx
stx SYSCTL1
dex
@2: stx SYSCTL1
rol
sty IODAT
bne @0
lda __iodat
sta IODAT
stz _FileBlockByte
lda #<($100-(>__BLOCKSIZE__))
sta _FileBlockByte+1
ply
plx
pla
pha
phx
phy
lda __iodat
and #$fc
tay
ora #2
tax
lda _FileCurrBlock
inc _FileCurrBlock
sec
bra @2
@0: bcc @1
stx IODAT
clc
@1: inx
stx SYSCTL1
dex
@2: stx SYSCTL1
rol
sty IODAT
bne @0
lda __iodat
sta IODAT
stz _FileBlockByte
lda #<($100-(>__BLOCKSIZE__))
sta _FileBlockByte+1
ply
plx
pla
exit: rts
exit: rts
.reloc
.reloc

View File

@@ -4,10 +4,10 @@
; char cgetc (void);
;
.export _cgetc
.import _kbhit
.import KBEDG
.import KBSTL
.export _cgetc
.import _kbhit
.import KBEDG
.import KBSTL
; --------------------------------------------------------------------------
; The Atari Lynx has a very small keyboard - only 3 keys
@@ -20,51 +20,51 @@
; So the keyboard returns '1', '2', '3', 'P', 'R', 'F' or '?'.
_cgetc:
lda KBSTL
ora KBEDG
bne @L1
jsr _kbhit ; Check for char available
tax ; Test result
bra _cgetc
lda KBSTL
ora KBEDG
bne @L1
jsr _kbhit ; Check for char available
tax ; Test result
bra _cgetc
@L1:
ldx #0
and #1
beq @L6
lda KBEDG ; Pause button is pressed
and #$0c
beq @L3
ora KBSTL
ldx #0
and #1
beq @L6
lda KBEDG ; Pause button is pressed
and #$0c
beq @L3
ora KBSTL
@L2:
bit #$04
beq @L4 ; Pause + Opt 1 = Reset
bit #$08
beq @L5 ; Pause + Opt 2 = Flip
lda #'?' ; All buttons pressed
rts
bit #$04
beq @L4 ; Pause + Opt 1 = Reset
bit #$08
beq @L5 ; Pause + Opt 2 = Flip
lda #'?' ; All buttons pressed
rts
@L3:
lda KBSTL ; Pause alone was the last placed button
and #$0c
bne @L2
lda #'P' ; Pause pressed
rts
lda KBSTL ; Pause alone was the last placed button
and #$0c
bne @L2
lda #'P' ; Pause pressed
rts
@L4:
lda #'R' ; Reset pressed
rts
lda #'R' ; Reset pressed
rts
@L5:
lda #'F' ; Flip pressed
rts
lda #'F' ; Flip pressed
rts
@L6:
lda KBEDG ; No Pause pressed
ora KBSTL
bit #$08
beq @L8
bit #$04
beq @L7
lda #'3' ; opt 1 + opt 2 pressed
rts
lda KBEDG ; No Pause pressed
ora KBSTL
bit #$08
beq @L8
bit #$04
beq @L7
lda #'3' ; opt 1 + opt 2 pressed
rts
@L7:
lda #'1' ; opt 1 pressed
rts
lda #'1' ; opt 1 pressed
rts
@L8:
lda #'2' ; opt 2 pressed
rts
lda #'2' ; opt 2 pressed
rts

View File

@@ -13,79 +13,79 @@
; If you change the numbers there, then change them here, too.
;
.export _clock, __clk_tck, clock_count
.interruptor update_clock, 2 ; (low priority)
.constructor init_clock
.export _clock, __clk_tck, clock_count
.interruptor update_clock, 2 ; (low priority)
.constructor init_clock
.import sreg: zp
.include "lynx.inc"
.import sreg: zp
.include "lynx.inc"
.macpack generic
.macpack generic
.proc _clock
php
sei ; Disable interrupts
.proc _clock
php
sei ; Disable interrupts
; Read the clock counter.
lda clock_count
ldx clock_count+1
ldy clock_count+2
lda clock_count
ldx clock_count+1
ldy clock_count+2
plp ; Re-enable interrupts
sty sreg
stz sreg+1 ; Promote 24 bits up to 32 bits
rts
.endproc
plp ; Re-enable interrupts
sty sreg
stz sreg+1 ; Promote 24 bits up to 32 bits
rts
.endproc
;-----------------------------------------------------------------------------
; Return the number of clock ticks in one second.
;
__clk_tck:
ldx #$00 ; >50, >60, >75
ldy PBKUP
lda #<75
cpy #$20 + 1
blt @ok
lda #<60
cpy #$29 + 1
blt @ok
lda #<50
@ok: stz sreg ; return 32 bits
stz sreg+1
rts
ldx #$00 ; >50, >60, >75
ldy PBKUP
lda #<75
cpy #$20 + 1
blt @ok
lda #<60
cpy #$29 + 1
blt @ok
lda #<50
@ok: stz sreg ; return 32 bits
stz sreg+1
rts
;-----------------------------------------------------------------------------
; This interrupt handler increments a 24-bit counter at every video
; vertical-blanking time.
;
.segment "LOWCODE"
.segment "LOWCODE"
update_clock:
lda INTSET
and #%00000100
beq @NotVBlank ; Not vertical-blank interrupt
lda INTSET
and #%00000100
beq @NotVBlank ; Not vertical-blank interrupt
inc clock_count
bne @L1
inc clock_count+1
bne @L1
inc clock_count+2
@L1: ;clc ; General interrupt was not reset
inc clock_count
bne @L1
inc clock_count+1
bne @L1
inc clock_count+2
@L1: ;clc ; General interrupt was not reset
@NotVBlank:
rts
rts
;-----------------------------------------------------------------------------
; Enable the interrupt that update_clock needs.
;
.segment "INIT"
.segment "INIT"
init_clock:
lda #%10000000
tsb VTIMCTLA
rts
lda #%10000000
tsb VTIMCTLA
rts
;-----------------------------------------------------------------------------
;
.bss
.bss
clock_count:
.res 3
.res 3

View File

@@ -15,122 +15,122 @@
; on the front of the fully linked binary (see EXEHDR segment.)
;
.export _exit
.export __STARTUP__ : absolute = 1 ; Mark as startup
.export _exit
.export __STARTUP__ : absolute = 1 ; Mark as startup
.import initlib, donelib
.import zerobss
.import callmain
.import _main
.import __RAM_START__, __RAM_SIZE__, __STACKSIZE__
.import initlib, donelib
.import zerobss
.import callmain
.import _main
.import __RAM_START__, __RAM_SIZE__, __STACKSIZE__
.include "zeropage.inc"
.include "extzp.inc"
.include "lynx.inc"
.include "zeropage.inc"
.include "extzp.inc"
.include "lynx.inc"
; ------------------------------------------------------------------------
; Mikey and Suzy init data, reg offsets and data
.rodata
.rodata
SuzyInitReg: .byte $28,$2a,$04,$06,$92,$83,$90
SuzyInitData: .byte $7f,$7f,$00,$00,$24,$f3,$01
SuzyInitReg: .byte $28,$2a,$04,$06,$92,$83,$90
SuzyInitData: .byte $7f,$7f,$00,$00,$24,$f3,$01
MikeyInitReg: .byte $00,$01,$08,$09,$20,$28,$30,$38,$44,$50,$8a,$8b,$8c,$92,$93
MikeyInitData: .byte $9e,$18,$68,$1f,$00,$00,$00,$00,$00,$ff,$1a,$1b,$04,$0d,$29
MikeyInitReg: .byte $00,$01,$08,$09,$20,$28,$30,$38,$44,$50,$8a,$8b,$8c,$92,$93
MikeyInitData: .byte $9e,$18,$68,$1f,$00,$00,$00,$00,$00,$ff,$1a,$1b,$04,$0d,$29
; ------------------------------------------------------------------------
; Actual code
.segment "STARTUP"
.segment "STARTUP"
; set up system
sei
cld
ldx #$FF
txs
sei
cld
ldx #$FF
txs
; init bank switching
lda #$C
sta MAPCTL ; $FFF9
lda #$C
sta MAPCTL ; $FFF9
; disable all timer interrupts
lda #$80
trb TIM0CTLA
trb TIM1CTLA
trb TIM2CTLA
trb TIM3CTLA
trb TIM5CTLA
trb TIM6CTLA
trb TIM7CTLA
lda #$80
trb TIM0CTLA
trb TIM1CTLA
trb TIM2CTLA
trb TIM3CTLA
trb TIM5CTLA
trb TIM6CTLA
trb TIM7CTLA
; disable TX/RX IRQ, set to 8E1
lda #%11101
sta SERCTL
lda #%11101
sta SERCTL
; clear all pending interrupts
lda INTSET
sta INTRST
lda INTSET
sta INTRST
; setup the stack
lda #<(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
sta sp
lda #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
sta sp+1
lda #<(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
sta sp
lda #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
sta sp+1
; Init Mickey
ldx #.sizeof(MikeyInitReg)-1
mloop: ldy MikeyInitReg,x
lda MikeyInitData,x
sta $fd00,y
dex
bpl mloop
ldx #.sizeof(MikeyInitReg)-1
mloop: ldy MikeyInitReg,x
lda MikeyInitData,x
sta $fd00,y
dex
bpl mloop
; these are RAM-shadows of read only regs
ldx #$1b
stx __iodat
dex ; $1A
stx __iodir
ldx #$d
stx __viddma
ldx #$1b
stx __iodat
dex ; $1A
stx __iodir
ldx #$d
stx __viddma
; Init Suzy
ldx #.sizeof(SuzyInitReg)-1
sloop: ldy SuzyInitReg,x
lda SuzyInitData,x
sta $fc00,y
dex
bpl sloop
ldx #.sizeof(SuzyInitReg)-1
sloop: ldy SuzyInitReg,x
lda SuzyInitData,x
sta $fc00,y
dex
bpl sloop
lda #$24
sta __sprsys
cli
lda #$24
sta __sprsys
cli
; Clear the BSS data
jsr zerobss
jsr zerobss
; 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: jsr donelib ; Run module destructors
_exit: jsr donelib ; Run module destructors
; Endless loop
noret: bra noret
noret: bra noret

View File

@@ -33,140 +33,140 @@
; 6 - Other whitespace (that is: '\f', '\n', '\r', '\t' and '\v')
; 7 - Space or tab character
.export __ctype
.export __ctype
__ctype:
.repeat 2 ; 2 times for normal and inverted
.byte $10 ; 0/00 ___ctrl_@___
.byte $10 ; 1/01 ___ctrl_A___
.byte $10 ; 2/02 ___ctrl_B___
.byte $10 ; 3/03 ___ctrl_C___
.byte $10 ; 4/04 ___ctrl_D___
.byte $10 ; 5/05 ___ctrl_E___
.byte $10 ; 6/06 ___ctrl_F___
.byte $10 ; 7/07 ___ctrl_G___
.byte $10 ; 8/08 ___ctrl_H___
.byte $D0 ; 9/09 ___ctrl_I___
.byte $50 ; 10/0a ___ctrl_J___
.byte $50 ; 11/0b ___ctrl_K___
.byte $50 ; 12/0c ___ctrl_L___
.byte $50 ; 13/0d ___ctrl_M___
.byte $10 ; 14/0e ___ctrl_N___
.byte $10 ; 15/0f ___ctrl_O___
.byte $10 ; 16/10 ___ctrl_P___
.byte $10 ; 17/11 ___ctrl_Q___
.byte $10 ; 18/12 ___ctrl_R___
.byte $10 ; 19/13 ___ctrl_S___
.byte $10 ; 20/14 ___ctrl_T___
.byte $10 ; 21/15 ___ctrl_U___
.byte $10 ; 22/16 ___ctrl_V___
.byte $10 ; 23/17 ___ctrl_W___
.byte $10 ; 24/18 ___ctrl_X___
.byte $10 ; 25/19 ___ctrl_Y___
.byte $10 ; 26/1a ___ctrl_Z___
.byte $10 ; 27/1b ___ctrl_[___
.byte $10 ; 28/1c ___ctrl_\___
.byte $10 ; 29/1d ___ctrl_]___
.byte $10 ; 30/1e ___ctrl_^___
.byte $10 ; 31/1f ___ctrl_____
.byte $A0 ; 32/20 ___SPACE___
.byte $00 ; 33/21 _____!_____
.byte $00 ; 34/22 _____"_____
.byte $00 ; 35/23 _____#_____
.byte $00 ; 36/24 _____$_____
.byte $00 ; 37/25 _____%_____
.byte $00 ; 38/26 _____&_____
.byte $00 ; 39/27 _____'_____
.byte $00 ; 40/28 _____(_____
.byte $00 ; 41/29 _____)_____
.byte $00 ; 42/2a _____*_____
.byte $00 ; 43/2b _____+_____
.byte $00 ; 44/2c _____,_____
.byte $00 ; 45/2d _____-_____
.byte $00 ; 46/2e _____._____
.byte $00 ; 47/2f _____/_____
.byte $0C ; 48/30 _____0_____
.byte $0C ; 49/31 _____1_____
.byte $0C ; 50/32 _____2_____
.byte $0C ; 51/33 _____3_____
.byte $0C ; 52/34 _____4_____
.byte $0C ; 53/35 _____5_____
.byte $0C ; 54/36 _____6_____
.byte $0C ; 55/37 _____7_____
.byte $0C ; 56/38 _____8_____
.byte $0C ; 57/39 _____9_____
.byte $00 ; 58/3a _____:_____
.byte $00 ; 59/3b _____;_____
.byte $00 ; 60/3c _____<_____
.byte $00 ; 61/3d _____=_____
.byte $00 ; 62/3e _____>_____
.byte $00 ; 63/3f _____?_____
.byte $10 ; 0/00 ___ctrl_@___
.byte $10 ; 1/01 ___ctrl_A___
.byte $10 ; 2/02 ___ctrl_B___
.byte $10 ; 3/03 ___ctrl_C___
.byte $10 ; 4/04 ___ctrl_D___
.byte $10 ; 5/05 ___ctrl_E___
.byte $10 ; 6/06 ___ctrl_F___
.byte $10 ; 7/07 ___ctrl_G___
.byte $10 ; 8/08 ___ctrl_H___
.byte $D0 ; 9/09 ___ctrl_I___
.byte $50 ; 10/0a ___ctrl_J___
.byte $50 ; 11/0b ___ctrl_K___
.byte $50 ; 12/0c ___ctrl_L___
.byte $50 ; 13/0d ___ctrl_M___
.byte $10 ; 14/0e ___ctrl_N___
.byte $10 ; 15/0f ___ctrl_O___
.byte $10 ; 16/10 ___ctrl_P___
.byte $10 ; 17/11 ___ctrl_Q___
.byte $10 ; 18/12 ___ctrl_R___
.byte $10 ; 19/13 ___ctrl_S___
.byte $10 ; 20/14 ___ctrl_T___
.byte $10 ; 21/15 ___ctrl_U___
.byte $10 ; 22/16 ___ctrl_V___
.byte $10 ; 23/17 ___ctrl_W___
.byte $10 ; 24/18 ___ctrl_X___
.byte $10 ; 25/19 ___ctrl_Y___
.byte $10 ; 26/1a ___ctrl_Z___
.byte $10 ; 27/1b ___ctrl_[___
.byte $10 ; 28/1c ___ctrl_\___
.byte $10 ; 29/1d ___ctrl_]___
.byte $10 ; 30/1e ___ctrl_^___
.byte $10 ; 31/1f ___ctrl_____
.byte $A0 ; 32/20 ___SPACE___
.byte $00 ; 33/21 _____!_____
.byte $00 ; 34/22 _____"_____
.byte $00 ; 35/23 _____#_____
.byte $00 ; 36/24 _____$_____
.byte $00 ; 37/25 _____%_____
.byte $00 ; 38/26 _____&_____
.byte $00 ; 39/27 _____'_____
.byte $00 ; 40/28 _____(_____
.byte $00 ; 41/29 _____)_____
.byte $00 ; 42/2a _____*_____
.byte $00 ; 43/2b _____+_____
.byte $00 ; 44/2c _____,_____
.byte $00 ; 45/2d _____-_____
.byte $00 ; 46/2e _____._____
.byte $00 ; 47/2f _____/_____
.byte $0C ; 48/30 _____0_____
.byte $0C ; 49/31 _____1_____
.byte $0C ; 50/32 _____2_____
.byte $0C ; 51/33 _____3_____
.byte $0C ; 52/34 _____4_____
.byte $0C ; 53/35 _____5_____
.byte $0C ; 54/36 _____6_____
.byte $0C ; 55/37 _____7_____
.byte $0C ; 56/38 _____8_____
.byte $0C ; 57/39 _____9_____
.byte $00 ; 58/3a _____:_____
.byte $00 ; 59/3b _____;_____
.byte $00 ; 60/3c _____<_____
.byte $00 ; 61/3d _____=_____
.byte $00 ; 62/3e _____>_____
.byte $00 ; 63/3f _____?_____
.byte $00 ; 64/40 _____@_____
.byte $0A ; 65/41 _____A_____
.byte $0A ; 66/42 _____B_____
.byte $0A ; 67/43 _____C_____
.byte $0A ; 68/44 _____D_____
.byte $0A ; 69/45 _____E_____
.byte $0A ; 70/46 _____F_____
.byte $02 ; 71/47 _____G_____
.byte $02 ; 72/48 _____H_____
.byte $02 ; 73/49 _____I_____
.byte $02 ; 74/4a _____J_____
.byte $02 ; 75/4b _____K_____
.byte $02 ; 76/4c _____L_____
.byte $02 ; 77/4d _____M_____
.byte $02 ; 78/4e _____N_____
.byte $02 ; 79/4f _____O_____
.byte $02 ; 80/50 _____P_____
.byte $02 ; 81/51 _____Q_____
.byte $02 ; 82/52 _____R_____
.byte $02 ; 83/53 _____S_____
.byte $02 ; 84/54 _____T_____
.byte $02 ; 85/55 _____U_____
.byte $02 ; 86/56 _____V_____
.byte $02 ; 87/57 _____W_____
.byte $02 ; 88/58 _____X_____
.byte $02 ; 89/59 _____Y_____
.byte $02 ; 90/5a _____Z_____
.byte $00 ; 91/5b _____[_____
.byte $00 ; 92/5c _____\_____
.byte $00 ; 93/5d _____]_____
.byte $00 ; 94/5e _____^_____
.byte $00 ; 95/5f _UNDERLINE_
.byte $00 ; 96/60 ___grave___
.byte $09 ; 97/61 _____a_____
.byte $09 ; 98/62 _____b_____
.byte $09 ; 99/63 _____c_____
.byte $09 ; 100/64 _____d_____
.byte $09 ; 101/65 _____e_____
.byte $09 ; 102/66 _____f_____
.byte $01 ; 103/67 _____g_____
.byte $01 ; 104/68 _____h_____
.byte $01 ; 105/69 _____i_____
.byte $01 ; 106/6a _____j_____
.byte $01 ; 107/6b _____k_____
.byte $01 ; 108/6c _____l_____
.byte $01 ; 109/6d _____m_____
.byte $01 ; 110/6e _____n_____
.byte $01 ; 111/6f _____o_____
.byte $01 ; 112/70 _____p_____
.byte $01 ; 113/71 _____q_____
.byte $01 ; 114/72 _____r_____
.byte $01 ; 115/73 _____s_____
.byte $01 ; 116/74 _____t_____
.byte $01 ; 117/75 _____u_____
.byte $01 ; 118/76 _____v_____
.byte $01 ; 119/77 _____w_____
.byte $01 ; 120/78 _____x_____
.byte $01 ; 121/79 _____y_____
.byte $01 ; 122/7a _____z_____
.byte $00 ; 123/7b _____{_____
.byte $00 ; 124/7c _____|_____
.byte $00 ; 125/7d _____}_____
.byte $00 ; 126/7e _____~_____
.byte $40 ; 127/7f ____DEL____
.byte $00 ; 64/40 _____@_____
.byte $0A ; 65/41 _____A_____
.byte $0A ; 66/42 _____B_____
.byte $0A ; 67/43 _____C_____
.byte $0A ; 68/44 _____D_____
.byte $0A ; 69/45 _____E_____
.byte $0A ; 70/46 _____F_____
.byte $02 ; 71/47 _____G_____
.byte $02 ; 72/48 _____H_____
.byte $02 ; 73/49 _____I_____
.byte $02 ; 74/4a _____J_____
.byte $02 ; 75/4b _____K_____
.byte $02 ; 76/4c _____L_____
.byte $02 ; 77/4d _____M_____
.byte $02 ; 78/4e _____N_____
.byte $02 ; 79/4f _____O_____
.byte $02 ; 80/50 _____P_____
.byte $02 ; 81/51 _____Q_____
.byte $02 ; 82/52 _____R_____
.byte $02 ; 83/53 _____S_____
.byte $02 ; 84/54 _____T_____
.byte $02 ; 85/55 _____U_____
.byte $02 ; 86/56 _____V_____
.byte $02 ; 87/57 _____W_____
.byte $02 ; 88/58 _____X_____
.byte $02 ; 89/59 _____Y_____
.byte $02 ; 90/5a _____Z_____
.byte $00 ; 91/5b _____[_____
.byte $00 ; 92/5c _____\_____
.byte $00 ; 93/5d _____]_____
.byte $00 ; 94/5e _____^_____
.byte $00 ; 95/5f _UNDERLINE_
.byte $00 ; 96/60 ___grave___
.byte $09 ; 97/61 _____a_____
.byte $09 ; 98/62 _____b_____
.byte $09 ; 99/63 _____c_____
.byte $09 ; 100/64 _____d_____
.byte $09 ; 101/65 _____e_____
.byte $09 ; 102/66 _____f_____
.byte $01 ; 103/67 _____g_____
.byte $01 ; 104/68 _____h_____
.byte $01 ; 105/69 _____i_____
.byte $01 ; 106/6a _____j_____
.byte $01 ; 107/6b _____k_____
.byte $01 ; 108/6c _____l_____
.byte $01 ; 109/6d _____m_____
.byte $01 ; 110/6e _____n_____
.byte $01 ; 111/6f _____o_____
.byte $01 ; 112/70 _____p_____
.byte $01 ; 113/71 _____q_____
.byte $01 ; 114/72 _____r_____
.byte $01 ; 115/73 _____s_____
.byte $01 ; 116/74 _____t_____
.byte $01 ; 117/75 _____u_____
.byte $01 ; 118/76 _____v_____
.byte $01 ; 119/77 _____w_____
.byte $01 ; 120/78 _____x_____
.byte $01 ; 121/79 _____y_____
.byte $01 ; 122/7a _____z_____
.byte $00 ; 123/7b _____{_____
.byte $00 ; 124/7c _____|_____
.byte $00 ; 125/7d _____}_____
.byte $00 ; 126/7e _____~_____
.byte $40 ; 127/7f ____DEL____
.endrepeat

View File

@@ -3,18 +3,18 @@
;
; A default directory with just the main executable.
;
.include "lynx.inc"
.import __STARTOFDIRECTORY__
.import __RAM_START__
.import __CODE_SIZE__,__DATA_SIZE__,__RODATA_SIZE__
.import __STARTUP_SIZE__,__INIT_SIZE__
.import __BLOCKSIZE__
.export __DEFDIR__: absolute = 1
.include "lynx.inc"
.import __STARTOFDIRECTORY__
.import __RAM_START__
.import __CODE_SIZE__,__DATA_SIZE__,__RODATA_SIZE__
.import __STARTUP_SIZE__,__INIT_SIZE__
.import __BLOCKSIZE__
.export __DEFDIR__: absolute = 1
; ------------------------------------------------------------------------
; Lynx directory
.segment "DIRECTORY"
.segment "DIRECTORY"
__DIRECTORY_START__:
off0=__STARTOFDIRECTORY__+(__DIRECTORY_END__-__DIRECTORY_START__)

View File

@@ -42,10 +42,10 @@
;****************
.export _lynx_eeprom_read
.export _lynx_eeprom_read
.export _lynx_eeprom_write
.export _lynx_eeprom_erase
.import popa
.import popa
.importzp ptr1
.include "lynx.inc"

View File

@@ -8,7 +8,7 @@
; 16.02.96 leaner (thanks to Harry)
; 12.03.96 test for busy after write and erase (well, Harry ;)) )
; 22.08.97 ported to ra65 for use with cc65
; 02.12.97 added xref for the new ra65
; 02.12.97 added xref for the new ra65
;
;
; (c) 1995..97 Bastian Schick
@@ -25,9 +25,9 @@
; +---| DI |- NC
;(32) AUDIN ----+---| DO |- GND
; ----------
.export _lynx_eeread_93c46
.export _lynx_eeread_93c46
.export _lynx_eewrite_93c46
.import popax
.import popax
.importzp ptr1
.include "lynx.inc"
@@ -45,160 +45,160 @@ EE_C_EWDS = $00
; /* Read a 16 bit word from the given address */
;
_lynx_eeread_93c46:
and #$3f
ora #EE_C_READ
jsr EE_Send9Bit
jsr EE_Read16Bit
lda ptr1
ldx ptr1+1
rts
and #$3f
ora #EE_C_READ
jsr EE_Send9Bit
jsr EE_Read16Bit
lda ptr1
ldx ptr1+1
rts
;***************
; reads EEPROM-word to ptr1
; A,Y destroyed
EE_Read16Bit:
lda #$a
sta IODIR ; set AUDIN to Input
clc
stz ptr1
stz ptr1+1
ldy #15
lda #$a
sta IODIR ; set AUDIN to Input
clc
stz ptr1
stz ptr1+1
ldy #15
EEloop1:
; CLK = 1
stz RCART0
stz RCART0
stz RCART0
stz RCART0
; CLK = 0
stz RCART0
stz RCART0
stz RCART0
stz RCART0
lda IODAT
and #$10 ; mask bit
adc #$f0 ; C=1 if A=$10
rol ptr1
rol ptr1+1 ; shifts 0 to Carry
dey
bpl EEloop1
lda IODAT
and #$10 ; mask bit
adc #$f0 ; C=1 if A=$10
rol ptr1
rol ptr1+1 ; shifts 0 to Carry
dey
bpl EEloop1
ldx #$1a
stx IODIR ; set AUDIN for output
ldx #$1a
stx IODIR ; set AUDIN for output
;EE_SET_CS_LOW
ldx #3
stx SYSCTL1
dex
stx SYSCTL1
ldx #3
stx SYSCTL1
dex
stx SYSCTL1
rts
rts
;***************
; write word to EEPROM
; void __fastcall__ lynx_eewrite_93c46(unsigned int addr, unsigned int val);
_lynx_eewrite_93c46:
sta ptr1
stx ptr1+1
lda #EE_C_EWEN
jsr EE_Send9Bit
jsr popax
and #$3f
ora #EE_C_WRITE
jsr EE_Send9Bit
jsr EE_Send16Bit ; Sends ptr1 that contains val
sta ptr1
stx ptr1+1
lda #EE_C_EWEN
jsr EE_Send9Bit
jsr popax
and #$3f
ora #EE_C_WRITE
jsr EE_Send9Bit
jsr EE_Send16Bit ; Sends ptr1 that contains val
EE_wait:
; EE_SET_CS_HIGH
ldx #63
ldx #63
EEloop:
stz RCART0
stz RCART0
dex
bpl EEloop
stz RCART0
stz RCART0
dex
bpl EEloop
lda #$0A
sta IODIR ; AUDIN to input
lda #$10
lda #$0A
sta IODIR ; AUDIN to input
lda #$10
EE_wait1:
bit IODAT ; 'til ready :D0-read is /D0-written
beq EE_wait1
lda #$1a ; AUDIN to output
sta IODIR
lda #EE_C_EWDS
; bra EE_Send9Bit ; fall into
bit IODAT ; 'til ready :D0-read is /D0-written
beq EE_wait1
lda #$1a ; AUDIN to output
sta IODIR
lda #EE_C_EWDS
; bra EE_Send9Bit ; fall into
;***************
; send A via I2C
; A,Y destroyed
;***************
EE_Send9Bit:
; EE_SET_CS_LOW
ldy #3
sty SYSCTL1
dey
sty SYSCTL1
ldy #3
sty SYSCTL1
dey
sty SYSCTL1
; EE_SET_CS_HIGH
ldy #63
ldy #63
EEloop2:
stz RCART0
stz RCART0
dey
bpl EEloop2
stz RCART0
stz RCART0
dey
bpl EEloop2
ldy #8
sec ; start bit
ror A
ror A
ror A
ror A ; bit 8 at pos. 4
ldy #8
sec ; start bit
ror A
ror A
ror A
ror A ; bit 8 at pos. 4
EEloop3:
tax
and #$10
ora #$b
sta IODAT
tax
and #$10
ora #$b
sta IODAT
; CLK = 1
stz RCART0
stz RCART0
stz RCART0
stz RCART0
; CLK = 0
stz RCART0
stz RCART0
txa
rol A
dey
bpl EEloop3
rts
stz RCART0
stz RCART0
txa
rol A
dey
bpl EEloop3
rts
;***************
; send ptr1 to EEPROM
EE_Send16Bit:
lda ptr1+1
lda ptr1+1
ror A
ror ptr1
ror A
ror ptr1
ror A
ror ptr1
ror A
ror ptr1
ror A
ror ptr1
ror A
ror ptr1
ldy #15
ldy #15
EEloop5:
tax
and #$10
ora #$b
sta IODAT
tax
and #$10
ora #$b
sta IODAT
; CLK = 1
stz RCART0
stz RCART0
stz RCART0
stz RCART0
; CLK = 0
stz RCART0
stz RCART0
txa
rol ptr1
rol A
dey
bpl EEloop5
stz RCART0
stz RCART0
txa
rol ptr1
rol A
dey
bpl EEloop5
; EE_SET_CS_LOW
ldx #3
stx SYSCTL1
dex
stx SYSCTL1
rts
ldx #3
stx SYSCTL1
dex
stx SYSCTL1
rts

View File

@@ -8,7 +8,7 @@
; 16.02.96 leaner (thanks to Harry)
; 12.03.96 test for busy after write and erase (well, Harry ;)) )
; 22.08.97 ported to ra65 for use with cc65
; 02.12.97 added xref for the new ra65
; 02.12.97 added xref for the new ra65
; 2010 93c66 support B. Spruck
; 2011 modified to suit cc65 environment Karri Kaksonen
;
@@ -27,12 +27,12 @@
;(32) AUDIN ----+---| DO |- GND
; ----------
.export _lynx_eeread_93c66
.export _lynx_eewrite_93c66
.import popax
.importzp ptr1
.export _lynx_eeread_93c66
.export _lynx_eewrite_93c66
.import popax
.importzp ptr1
.include "lynx.inc"
.include "lynx.inc"
; -------------------
; EEPROM command list
@@ -48,180 +48,180 @@ EE_C_EWDS2 = $00
; Only lower byte in A is used for address
; unsigned int __fastcall__ lynx_eeread_93c66(unsigned int addr);
_lynx_eeread_93c66:
ldx #EE_C_READ
jsr EE_Send11Bit
jsr EE_Read16Bit
lda ptr1
ldx ptr1+1
rts
ldx #EE_C_READ
jsr EE_Send11Bit
jsr EE_Read16Bit
lda ptr1
ldx ptr1+1
rts
;***************
; reads EEPROM-word to ptr1
; A,Y destroyed
EE_Read16Bit:
lda #$a
sta IODIR ; set AUDIN to Input
clc
stz ptr1
stz ptr1+1
ldy #15
lda #$a
sta IODIR ; set AUDIN to Input
clc
stz ptr1
stz ptr1+1
ldy #15
EEloop1:
; CLK = 1
stz RCART0
stz RCART0
stz RCART0
stz RCART0
; CLK = 0
stz RCART0
stz RCART0
stz RCART0
stz RCART0
lda IODAT
and #$10 ; mask bit
adc #$f0 ; C=1 if A=$10
rol ptr1
rol ptr1+1 ; shifts 0 to Carry
dey
bpl EEloop1
lda IODAT
and #$10 ; mask bit
adc #$f0 ; C=1 if A=$10
rol ptr1
rol ptr1+1 ; shifts 0 to Carry
dey
bpl EEloop1
ldx #$1a
stx IODIR ; set AUDIN for output
ldx #$1a
stx IODIR ; set AUDIN for output
;EE_SET_CS_LOW
ldx #3
stx SYSCTL1
dex
stx SYSCTL1
ldx #3
stx SYSCTL1
dex
stx SYSCTL1
rts
rts
;***************
; write word to EEPROM
; void __fastcall__ lynx_eewrite_93c66(unsigned int addr, unsigned int val);
_lynx_eewrite_93c66:
sta ptr1
stx ptr1+1
ldx #EE_C_EWEN
lda #EE_C_EWEN2
jsr EE_Send11Bit
jsr popax
ldx #EE_C_WRITE
jsr EE_Send11Bit
jsr EE_Send16Bit ; Sends ptr1 that contains val
sta ptr1
stx ptr1+1
ldx #EE_C_EWEN
lda #EE_C_EWEN2
jsr EE_Send11Bit
jsr popax
ldx #EE_C_WRITE
jsr EE_Send11Bit
jsr EE_Send16Bit ; Sends ptr1 that contains val
EE_wait:
; EE_SET_CS_HIGH
ldx #63
ldx #63
EEloop:
stz RCART0
stz RCART0
dex
bpl EEloop
stz RCART0
stz RCART0
dex
bpl EEloop
lda #$0A
sta IODIR ; AUDIN to input
lda #$10
lda #$0A
sta IODIR ; AUDIN to input
lda #$10
EE_wait1:
bit IODAT ; 'til ready :D0-read is /D0-written
beq EE_wait1
lda #$1a ; AUDIN to output
sta IODIR
ldx #EE_C_EWDS
lda #EE_C_EWDS2
; bra EE_Send11Bit ; fall into
bit IODAT ; 'til ready :D0-read is /D0-written
beq EE_wait1
lda #$1a ; AUDIN to output
sta IODIR
ldx #EE_C_EWDS
lda #EE_C_EWDS2
; bra EE_Send11Bit ; fall into
;***************
; send A via I2C
; A,Y destroyed
EE_Send11Bit:
; EE_SET_CS_LOW
ldy #3
sty SYSCTL1
dey
sty SYSCTL1
ldy #3
sty SYSCTL1
dey
sty SYSCTL1
; EE_SET_CS_HIGH
ldy #63
ldy #63
EEloop2:
stz RCART0
stz RCART0
dey
bpl EEloop2
stz RCART0
stz RCART0
dey
bpl EEloop2
pha
txa ;; Ok erstmal x abarbeiten und A sichern
ldy #2 ; 3 times
pha
txa ;; Ok erstmal x abarbeiten und A sichern
ldy #2 ; 3 times
EEloop3:
tax
and #$10
ora #$b
sta IODAT
tax
and #$10
ora #$b
sta IODAT
; CLK = 1
stz RCART0
stz RCART0
stz RCART0
stz RCART0
; CLK = 0
stz RCART0
stz RCART0
txa
rol A
dey
bpl EEloop3
stz RCART0
stz RCART0
txa
rol A
dey
bpl EEloop3
ldy #7 ; 8 times
pla ;; jetzt kommt a an die reihe
ldy #7 ; 8 times
pla ;; jetzt kommt a an die reihe
ror A
ror A
ror A ; bit 7 at pos. 4
ror A
ror A
ror A ; bit 7 at pos. 4
EEloop4:
tax
and #$10
tax
and #$10
ora #$b
sta IODAT
ora #$b
sta IODAT
; CLK = 1
stz RCART0
stz RCART0
stz RCART0
stz RCART0
; CLK = 0
stz RCART0
stz RCART0
txa
rol A
dey
bpl EEloop4
rts
stz RCART0
stz RCART0
txa
rol A
dey
bpl EEloop4
rts
;***************
; send ptr1 to EEPROM
EE_Send16Bit:
lda ptr1+1
lda ptr1+1
ror A
ror ptr1
ror A
ror ptr1
ror A
ror ptr1
ror A
ror ptr1
ror A
ror ptr1
ror A
ror ptr1
ldy #15
ldy #15
EEloop5:
tax
and #$10
ora #$b
sta IODAT
tax
and #$10
ora #$b
sta IODAT
; CLK = 1
stz RCART0
stz RCART0
stz RCART0
stz RCART0
; CLK = 0
stz RCART0
stz RCART0
txa
rol ptr1
rol A
dey
bpl EEloop5
stz RCART0
stz RCART0
txa
rol ptr1
rol A
dey
bpl EEloop5
; EE_SET_CS_LOW
ldx #3
stx SYSCTL1
dex
stx SYSCTL1
rts
ldx #3
stx SYSCTL1
dex
stx SYSCTL1
rts

View File

@@ -8,7 +8,7 @@
; 16.02.96 leaner (thanks to Harry)
; 12.03.96 test for busy after write and erase (well, Harry ;)) )
; 22.08.97 ported to ra65 for use with cc65
; 02.12.97 added xref for the new ra65
; 02.12.97 added xref for the new ra65
; 2010 93c66 support B. Spruck
; 2010 93c86 support B. Spruck
; 2011 modified to suit cc65 environment Karri Kaksonen
@@ -28,12 +28,12 @@
;(32) AUDIN ----+---| DO |- GND
; ----------
.export _lynx_eeread_93c86
.export _lynx_eewrite_93c86
.import popax
.importzp ptr1
.export _lynx_eeread_93c86
.export _lynx_eewrite_93c86
.import popax
.importzp ptr1
.include "lynx.inc"
.include "lynx.inc"
; -------------------
; EEPROM command list
@@ -49,188 +49,188 @@ EE_C_EWDS2 = $00
; Only lower byte in A is used for address
; unsigned int __fastcall__ lynx_eeread_93c86(unsigned int addr);
_lynx_eeread_93c86:
pha
txa
ora #EE_C_READ
tax
pla
jsr EE_Send13Bit
jsr EE_Read16Bit
lda ptr1
ldx ptr1+1
rts
pha
txa
ora #EE_C_READ
tax
pla
jsr EE_Send13Bit
jsr EE_Read16Bit
lda ptr1
ldx ptr1+1
rts
;***************
; reads EEPROM-word to ptr1
; A,Y destroyed
EE_Read16Bit:
lda #$a
sta IODIR ; set AUDIN to Input
clc
stz ptr1
stz ptr1+1
ldy #15
lda #$a
sta IODIR ; set AUDIN to Input
clc
stz ptr1
stz ptr1+1
ldy #15
EEloop1:
; CLK = 1
stz RCART0
stz RCART0
stz RCART0
stz RCART0
; CLK = 0
stz RCART0
stz RCART0
stz RCART0
stz RCART0
lda IODAT
and #$10 ; mask bit
adc #$f0 ; C=1 if A=$10
rol ptr1
rol ptr1+1 ; shifts 0 to Carry
dey
bpl EEloop1
lda IODAT
and #$10 ; mask bit
adc #$f0 ; C=1 if A=$10
rol ptr1
rol ptr1+1 ; shifts 0 to Carry
dey
bpl EEloop1
ldx #$1a
stx IODIR ; set AUDIN for output
ldx #$1a
stx IODIR ; set AUDIN for output
;EE_SET_CS_LOW
ldx #3
stx SYSCTL1
dex
stx SYSCTL1
ldx #3
stx SYSCTL1
dex
stx SYSCTL1
rts
rts
;***************
; write word to EEPROM
; void __fastcall__ lynx_eewrite_93c86(unsigned int addr, unsigned int val);
_lynx_eewrite_93c86:
sta ptr1
stx ptr1+1
ldx #EE_C_EWEN
lda #EE_C_EWEN2
jsr EE_Send13Bit
jsr popax
pha
txa
ora #EE_C_WRITE
tax
pla
jsr EE_Send13Bit
jsr EE_Send16Bit ; Sends ptr1 that contains val
sta ptr1
stx ptr1+1
ldx #EE_C_EWEN
lda #EE_C_EWEN2
jsr EE_Send13Bit
jsr popax
pha
txa
ora #EE_C_WRITE
tax
pla
jsr EE_Send13Bit
jsr EE_Send16Bit ; Sends ptr1 that contains val
EE_wait:
; EE_SET_CS_HIGH
ldx #63
ldx #63
EEloop:
stz RCART0
stz RCART0
dex
bpl EEloop
stz RCART0
stz RCART0
dex
bpl EEloop
lda #$0A
sta IODIR ; AUDIN to input
lda #$10
lda #$0A
sta IODIR ; AUDIN to input
lda #$10
EE_wait1:
bit IODAT ; 'til ready :D0-read is /D0-written
beq EE_wait1
lda #$1a ; AUDIN to output
sta IODIR
ldx #EE_C_EWDS
lda #EE_C_EWDS2
; bra EE_Send13Bit ; fall into
bit IODAT ; 'til ready :D0-read is /D0-written
beq EE_wait1
lda #$1a ; AUDIN to output
sta IODIR
ldx #EE_C_EWDS
lda #EE_C_EWDS2
; bra EE_Send13Bit ; fall into
;***************
; send A via I2C
; A,Y destroyed
EE_Send13Bit:
; EE_SET_CS_LOW
ldy #3
sty SYSCTL1
dey
sty SYSCTL1
ldy #3
sty SYSCTL1
dey
sty SYSCTL1
; EE_SET_CS_HIGH
ldy #63
ldy #63
EEloop2:
stz RCART0
stz RCART0
dey
bpl EEloop2
stz RCART0
stz RCART0
dey
bpl EEloop2
pha
txa ;; Ok erstmal x abarbeiten und A sichern
ldy #4 ; 5 times
pha
txa ;; Ok erstmal x abarbeiten und A sichern
ldy #4 ; 5 times
EEloop3:
tax
and #$10
ora #$b
sta IODAT
tax
and #$10
ora #$b
sta IODAT
; CLK = 1
stz RCART0
stz RCART0
stz RCART0
stz RCART0
; CLK = 0
stz RCART0
stz RCART0
txa
rol A
dey
bpl EEloop3
stz RCART0
stz RCART0
txa
rol A
dey
bpl EEloop3
ldy #7 ; 8 times
pla ;; jetzt kommt a an die reihe
ldy #7 ; 8 times
pla ;; jetzt kommt a an die reihe
ror A
ror A
ror A ; bit 7 at pos. 4
ror A
ror A
ror A ; bit 7 at pos. 4
EEloop4:
tax
and #$10
tax
and #$10
ora #$b
sta IODAT
ora #$b
sta IODAT
; CLK = 1
stz RCART0
stz RCART0
stz RCART0
stz RCART0
; CLK = 0
stz RCART0
stz RCART0
txa
rol A
dey
bpl EEloop4
rts
stz RCART0
stz RCART0
txa
rol A
dey
bpl EEloop4
rts
;***************
; send ptr1 to EEPROM
EE_Send16Bit:
lda ptr1+1
lda ptr1+1
ror A
ror ptr1
ror A
ror ptr1
ror A
ror ptr1
ror A
ror ptr1
ror A
ror ptr1
ror A
ror ptr1
ldy #15
ldy #15
EEloop5:
tax
and #$10
ora #$b
sta IODAT
tax
and #$10
ora #$b
sta IODAT
; CLK = 1
stz RCART0
stz RCART0
stz RCART0
stz RCART0
; CLK = 0
stz RCART0
stz RCART0
txa
rol ptr1
rol A
dey
bpl EEloop5
stz RCART0
stz RCART0
txa
rol ptr1
rol A
dey
bpl EEloop5
; EE_SET_CS_LOW
ldx #3
stx SYSCTL1
dex
stx SYSCTL1
rts
ldx #3
stx SYSCTL1
dex
stx SYSCTL1
rts

View File

@@ -9,26 +9,26 @@
;
; void lynx_exec(int fileno)
;
.importzp _FileDestAddr
.import pushax,ldax0sp,incsp2
.import _lynx_load
.export _lynx_exec
.importzp _FileDestAddr
.import pushax,ldax0sp,incsp2
.import _lynx_load
.export _lynx_exec
; ---------------------------------------------------------------
; void __near__ __fastcall__ lynx_exec (int)
; ---------------------------------------------------------------
.segment "CODE"
.segment "CODE"
.proc _lynx_exec: near
.proc _lynx_exec: near
.segment "CODE"
.segment "CODE"
jsr pushax
jsr ldax0sp
jsr _lynx_load
jsr incsp2
jmp (_FileDestAddr)
jsr pushax
jsr ldax0sp
jsr _lynx_load
jsr incsp2
jmp (_FileDestAddr)
.endproc

View File

@@ -3,20 +3,20 @@
;
; This header contains data for emulators like Handy and Mednafen
;
.import __BLOCKSIZE__
.export __EXEHDR__: absolute = 1
.import __BLOCKSIZE__
.export __EXEHDR__: absolute = 1
; ------------------------------------------------------------------------
; EXE header
.segment "EXEHDR"
.byte 'L','Y','N','X' ; magic
.word __BLOCKSIZE__ ; bank 0 page size
.word __BLOCKSIZE__ ; bank 1 page size
.word 1 ; version number
.asciiz "Cart name " ; 32 bytes cart name
.asciiz "Manufacturer " ; 16 bytes manufacturer
.byte 0 ; rotation 1=left
; rotation 2=right
.byte 0,0,0,0,0 ; spare
.segment "EXEHDR"
.byte 'L','Y','N','X' ; magic
.word __BLOCKSIZE__ ; bank 0 page size
.word __BLOCKSIZE__ ; bank 1 page size
.word 1 ; version number
.asciiz "Cart name " ; 32 bytes cart name
.asciiz "Manufacturer " ; 16 bytes manufacturer
.byte 0 ; rotation 1=left
; rotation 2=right
.byte 0,0,0,0,0 ; spare

View File

@@ -8,23 +8,23 @@
;
.global __iodat: zp
.global __iodat: zp
.global __iodir: zp
.global __viddma: zp
.global __sprsys: zp
.global _abc_score_ptr0: zp
.global _abc_score_ptr1: zp
.global _abc_score_ptr2: zp
.global _abc_score_ptr3: zp
.global _FileEntry: zp
.global _FileStartBlock: zp
.global _FileBlockOffset: zp
.global _FileExecFlag: zp
.global _FileDestAddr: zp
.global _FileFileLen: zp
.global _FileCurrBlock: zp
.global _FileBlockByte: zp
.global _FileDestPtr: zp
.global _abc_score_ptr0: zp
.global _abc_score_ptr1: zp
.global _abc_score_ptr2: zp
.global _abc_score_ptr3: zp
.global _FileEntry: zp
.global _FileStartBlock: zp
.global _FileBlockOffset: zp
.global _FileExecFlag: zp
.global _FileDestAddr: zp
.global _FileFileLen: zp
.global _FileCurrBlock: zp
.global _FileBlockByte: zp
.global _FileDestPtr: zp

View File

@@ -25,7 +25,7 @@ _abc_score_ptr3: .res 2
; ------------------------------------------------------------------------
; Filesystem variables needed for reading stuff from the Lynx cart
_FileEntry: ; The file directory entry is 8 bytes
_FileEntry: ; The file directory entry is 8 bytes
_FileStartBlock: .res 1
_FileBlockOffset: .res 2
_FileExecFlag: .res 1

View File

@@ -2,45 +2,45 @@
; IRQ handling (Lynx version)
;
.export initirq, doneirq
.import callirq
.export initirq, doneirq
.import callirq
.include "lynx.inc"
.include "lynx.inc"
; ------------------------------------------------------------------------
.segment "INIT"
.segment "INIT"
initirq:
lda #<IRQStub
ldx #>IRQStub
sei
sta INTVECTL
stx INTVECTH
cli
rts
lda #<IRQStub
ldx #>IRQStub
sei
sta INTVECTL
stx INTVECTH
cli
rts
; ------------------------------------------------------------------------
.code
doneirq:
; as Lynx is a console there is not much point in releasing the IRQ
rts
; as Lynx is a console there is not much point in releasing the IRQ
rts
; ------------------------------------------------------------------------
.segment "LOWCODE"
.segment "LOWCODE"
IRQStub:
phy
phx
pha
cld
jsr callirq
lda INTSET
sta INTRST
pla
plx
ply
rti
phy
phx
pha
cld
jsr callirq
lda INTSET
sta INTRST
pla
plx
ply
rti

View File

@@ -7,9 +7,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 "lynx.inc"
@@ -23,7 +23,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)
@@ -68,7 +68,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.
@@ -92,7 +92,7 @@ COUNT:
; READ: Read a particular joystick passed in A.
READ:
ldx #$00 ; Clear high byte
ldx #$00 ; Clear high byte
lda JOYSTICK ; Read joystick
and #$F3 ; Mask relevant keys
rts

View File

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

View File

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

View File

@@ -4,10 +4,10 @@
; unsigned char kbhit (void);
;
.export _kbhit
.export KBEDG
.export KBSTL
.import return1
.export _kbhit
.export KBEDG
.export KBSTL
.import return1
; --------------------------------------------------------------------------
; The Atari Lynx has a very small keyboard - only 3 keys
@@ -19,38 +19,38 @@
; and Opt1 + Opt2 pressed '3'.
; So the keyboard returns '1', '2', '3', 'P', 'R', 'F' or '?'.
.data
KBTMP: .byte 0
KBPRV: .byte 0
KBEDG: .byte 0
KBSTL: .byte 0
KBDEB: .byte 0
KBNPR: .byte 0
.data
KBTMP: .byte 0
KBPRV: .byte 0
KBEDG: .byte 0
KBSTL: .byte 0
KBDEB: .byte 0
KBNPR: .byte 0
.code
.code
_kbhit:
lda $FCB0 ; Read the Opt buttons
and #$0c
sta KBTMP
lda $FCB1 ; Read Pause
and #1
ora KBTMP ; 0000210P
tax
and KBPRV
sta KBSTL ; for multibutton
txa
and KBDEB
sta KBEDG ; for just depressed
txa
and KBNPR
sta KBDEB ; for debouncing
txa
eor #$ff
sta KBNPR ; inverted previous ones pressed
stx KBPRV
lda KBEDG
beq @L1
jmp return1 ; Key hit
lda $FCB0 ; Read the Opt buttons
and #$0c
sta KBTMP
lda $FCB1 ; Read Pause
and #1
ora KBTMP ; 0000210P
tax
and KBPRV
sta KBSTL ; for multibutton
txa
and KBDEB
sta KBEDG ; for just depressed
txa
and KBNPR
sta KBDEB ; for debouncing
txa
eor #$ff
sta KBNPR ; inverted previous ones pressed
stx KBPRV
lda KBEDG
beq @L1
jmp return1 ; Key hit
@L1: tax ; No new keys hit
rts

View File

@@ -7,35 +7,35 @@
;
; void lynx_load(int fileno)
;
.importzp _FileFileLen
.importzp _FileDestAddr
.import pushax,ldax0sp,pusha0,incsp2
.import _openn
.import _read
.export _lynx_load
.importzp _FileFileLen
.importzp _FileDestAddr
.import pushax,ldax0sp,pusha0,incsp2
.import _openn
.import _read
.export _lynx_load
; ---------------------------------------------------------------
; void __near__ __fastcall__ lynx_load (int)
; ---------------------------------------------------------------
.segment "CODE"
.segment "CODE"
.proc _lynx_load: near
.proc _lynx_load: near
.segment "CODE"
.segment "CODE"
jsr pushax
jsr ldax0sp
jsr _openn
lda #$01
jsr pusha0
lda _FileDestAddr
ldx _FileDestAddr+1
jsr pushax
lda _FileFileLen
ldx _FileFileLen+1
jsr _read
jmp incsp2
jsr pushax
jsr ldax0sp
jsr _openn
lda #$01
jsr pusha0
lda _FileDestAddr
ldx _FileDestAddr+1
jsr pushax
lda _FileFileLen
ldx _FileFileLen+1
jsr _read
jmp incsp2
.endproc

View File

@@ -11,48 +11,48 @@
;
; off_t __fastcall__ lseek(int fd, off_t offset, int whence);
.importzp sp, sreg, regsave, regbank, tmp1, ptr1, ptr2
.macpack longbranch
.export _lseek
.import addysp, stax0sp, tosand0ax, pusheax, asreax2
.import ldeaxysp, decsp2, pushax, incsp8
.import tosandeax,decax1,tosdiveax,axlong,ldaxysp
.import lynxskip0, lynxblock,tosasreax
.import __BLOCKSIZE__
.importzp _FileCurrBlock
.importzp sp, sreg, regsave, regbank, tmp1, ptr1, ptr2
.macpack longbranch
.export _lseek
.import addysp, stax0sp, tosand0ax, pusheax, asreax2
.import ldeaxysp, decsp2, pushax, incsp8
.import tosandeax,decax1,tosdiveax,axlong,ldaxysp
.import lynxskip0, lynxblock,tosasreax
.import __BLOCKSIZE__
.importzp _FileCurrBlock
.segment "CODE"
.segment "CODE"
.proc _lseek: near
.proc _lseek: near
.segment "CODE"
.segment "CODE"
jsr pushax
ldy #$05
jsr ldeaxysp
jsr pusheax
ldx #$00
lda #<(__BLOCKSIZE__/1024 + 9)
jsr tosasreax
sta _FileCurrBlock
jsr lynxblock
ldy #$05
jsr ldeaxysp
jsr pusheax
lda #<(__BLOCKSIZE__-1)
ldx #>(__BLOCKSIZE__-1)
jsr axlong
jsr tosandeax
eor #$FF
pha
txa
eor #$FF
tay
plx
jsr lynxskip0
ldy #$05
jsr ldeaxysp
jmp incsp8
jsr pushax
ldy #$05
jsr ldeaxysp
jsr pusheax
ldx #$00
lda #<(__BLOCKSIZE__/1024 + 9)
jsr tosasreax
sta _FileCurrBlock
jsr lynxblock
ldy #$05
jsr ldeaxysp
jsr pusheax
lda #<(__BLOCKSIZE__-1)
ldx #>(__BLOCKSIZE__-1)
jsr axlong
jsr tosandeax
eor #$FF
pha
txa
eor #$FF
tay
plx
jsr lynxskip0
ldy #$05
jsr ldeaxysp
jmp incsp8
.endproc

View File

@@ -13,86 +13,86 @@
; with 1024 bytes/block carts that are using CART0 as a read strobe.
; Also the default crt0.s supports this most common Lynx cart format.
.include "lynx.inc"
.include "extzp.inc"
.export lynxskip0, lynxread0
.export lynxblock
.import __BLOCKSIZE__
.include "lynx.inc"
.include "extzp.inc"
.export lynxskip0, lynxread0
.export lynxblock
.import __BLOCKSIZE__
.code
.code
;**********************************
; Skip bytes on bank 0
; X:Y count (EOR $FFFF)
;**********************************
lynxskip0:
inx
bne @0
iny
beq exit
@0: jsr readbyte0
bra lynxskip0
inx
bne @0
iny
beq exit
@0: jsr readbyte0
bra lynxskip0
;**********************************
; Read bytes from bank 0
; X:Y count (EOR $ffff)
;**********************************
lynxread0:
inx
bne @1
iny
beq exit
@1: jsr readbyte0
sta (_FileDestPtr)
inc _FileDestPtr
bne lynxread0
inc _FileDestPtr+1
bra lynxread0
inx
bne @1
iny
beq exit
@1: jsr readbyte0
sta (_FileDestPtr)
inc _FileDestPtr
bne lynxread0
inc _FileDestPtr+1
bra lynxread0
;**********************************
; Read one byte from cartridge
;**********************************
readbyte0:
lda RCART0
inc _FileBlockByte
bne exit
inc _FileBlockByte+1
bne exit
lda RCART0
inc _FileBlockByte
bne exit
inc _FileBlockByte+1
bne exit
;**********************************
; Select a block
;**********************************
lynxblock:
pha
phx
phy
lda __iodat
and #$fc
tay
ora #2
tax
lda _FileCurrBlock
inc _FileCurrBlock
sec
bra @2
@0: bcc @1
stx IODAT
clc
@1: inx
stx SYSCTL1
dex
@2: stx SYSCTL1
rol
sty IODAT
bne @0
lda __iodat
sta IODAT
stz _FileBlockByte
lda #<($100-(>__BLOCKSIZE__))
sta _FileBlockByte+1
ply
plx
pla
pha
phx
phy
lda __iodat
and #$fc
tay
ora #2
tax
lda _FileCurrBlock
inc _FileCurrBlock
sec
bra @2
@0: bcc @1
stx IODAT
clc
@1: inx
stx SYSCTL1
dex
@2: stx SYSCTL1
rol
sty IODAT
bne @0
lda __iodat
sta IODAT
stz _FileBlockByte
lda #<($100-(>__BLOCKSIZE__))
sta _FileBlockByte+1
ply
plx
pla
exit: rts
exit: rts

File diff suppressed because it is too large Load Diff

View File

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

View File

@@ -15,67 +15,67 @@
; As helper functions we also provide.
; void openn(int fileno)
;
.importzp sreg, tmp3
.macpack longbranch
.import _atoi
.import _read
.import _lseek
.import addysp,popax,pushax,decsp6,pusha0,pusheax,ldaxysp
.import aslax3,axlong,tosaddeax,steaxysp,stax0sp,incsp8
.import ldax0sp
.import lynxskip0, lynxblock
.importzp _FileEntry
.importzp _FileStartBlock
.importzp _FileCurrBlock
.importzp _FileBlockOffset
.import __STARTOFDIRECTORY__
.export _open
.export _openn
.importzp sreg, tmp3
.macpack longbranch
.import _atoi
.import _read
.import _lseek
.import addysp,popax,pushax,decsp6,pusha0,pusheax,ldaxysp
.import aslax3,axlong,tosaddeax,steaxysp,stax0sp,incsp8
.import ldax0sp
.import lynxskip0, lynxblock
.importzp _FileEntry
.importzp _FileStartBlock
.importzp _FileCurrBlock
.importzp _FileBlockOffset
.import __STARTOFDIRECTORY__
.export _open
.export _openn
.include "errno.inc"
.include "fcntl.inc"
.include "errno.inc"
.include "fcntl.inc"
.segment "DATA"
.segment "DATA"
_startofdirectory:
.dword __STARTOFDIRECTORY__
.dword __STARTOFDIRECTORY__
; ---------------------------------------------------------------
; int __near__ open (__near__ const unsigned char*, int)
; ---------------------------------------------------------------
.segment "CODE"
.segment "CODE"
.proc _open
.proc _open
.segment "CODE"
.segment "CODE"
dey
dey
dey
dey
beq parmok
jsr addysp
dey
dey
dey
dey
beq parmok
jsr addysp
parmok: jsr popax
sta tmp3
and #(O_RDWR | O_CREAT)
cmp #O_RDONLY
beq flagsok
cmp #(O_WRONLY | O_CREAT)
beq flagsok
jsr popax
lda #EINVAL
jmp __directerrno
parmok: jsr popax
sta tmp3
and #(O_RDWR | O_CREAT)
cmp #O_RDONLY
beq flagsok
cmp #(O_WRONLY | O_CREAT)
beq flagsok
jsr popax
lda #EINVAL
jmp __directerrno
flagsok:
jsr popax
jsr _atoi
jsr _openn
ldx #$00
lda #$01
stx __oserror
rts
jsr popax
jsr _atoi
jsr _openn
ldx #$00
lda #$01
stx __oserror
rts
.endproc
@@ -83,54 +83,54 @@ flagsok:
; void __near__ __fastcall__ openn (int)
; ---------------------------------------------------------------
.segment "CODE"
.segment "CODE"
.proc _openn: near
.proc _openn: near
.segment "CODE"
.segment "CODE"
jsr pushax
jsr decsp6
lda #$01
jsr pusha0
lda _startofdirectory+3
sta sreg+1
lda _startofdirectory+2
sta sreg
ldx _startofdirectory+1
lda _startofdirectory
jsr pusheax
ldy #$0D
jsr ldaxysp
jsr aslax3
jsr axlong
jsr tosaddeax
jsr pusheax
ldx #$00
txa
jsr _lseek
ldy #$02
jsr steaxysp
lda #$01
jsr pusha0
lda #<_FileEntry
ldx #>_FileEntry
jsr pushax
ldx #$00
lda #$08
jsr _read
lda _FileStartBlock
sta _FileCurrBlock
jsr lynxblock
lda _FileBlockOffset+1
eor #$FF
tay
lda _FileBlockOffset
eor #$FF
tax
jsr lynxskip0
jsr stax0sp
jmp incsp8
jsr pushax
jsr decsp6
lda #$01
jsr pusha0
lda _startofdirectory+3
sta sreg+1
lda _startofdirectory+2
sta sreg
ldx _startofdirectory+1
lda _startofdirectory
jsr pusheax
ldy #$0D
jsr ldaxysp
jsr aslax3
jsr axlong
jsr tosaddeax
jsr pusheax
ldx #$00
txa
jsr _lseek
ldy #$02
jsr steaxysp
lda #$01
jsr pusha0
lda #<_FileEntry
ldx #>_FileEntry
jsr pushax
ldx #$00
lda #$08
jsr _read
lda _FileStartBlock
sta _FileCurrBlock
jsr lynxblock
lda _FileBlockOffset+1
eor #$FF
tay
lda _FileBlockOffset
eor #$FF
tax
jsr lynxskip0
jsr stax0sp
jmp incsp8
.endproc

View File

@@ -5,10 +5,10 @@
; /* Map a system specific error into a system independent code */
;
.include "errno.inc"
.include "errno.inc"
.code
__osmaperrno:
rts
rts

View File

@@ -12,33 +12,33 @@
;
; int __fastcall__ read(int fd,void *buf,int count)
;
.importzp _FileDestPtr
.import lynxread0
.import pushax,ldaxysp,ldax0sp,incsp6
.export _read
.importzp _FileDestPtr
.import lynxread0
.import pushax,ldaxysp,ldax0sp,incsp6
.export _read
.segment "CODE"
.segment "CODE"
.proc _read: near
.proc _read: near
.segment "CODE"
.segment "CODE"
jsr pushax
ldy #$03
jsr ldaxysp
sta _FileDestPtr
stx _FileDestPtr+1
jsr ldax0sp
pha
jsr pushax
ldy #$03
jsr ldaxysp
sta _FileDestPtr
stx _FileDestPtr+1
jsr ldax0sp
pha
txa
eor #$FF
tay
pla
eor #$FF
tax
jsr lynxread0
jsr ldax0sp
jmp incsp6
eor #$FF
tay
pla
eor #$FF
tax
jsr lynxread0
jsr ldax0sp
jmp incsp6
.endproc

View File

@@ -4,48 +4,48 @@
; Karri Kaksonen, 17.09.2009
;
.include "lynx.inc"
.include "zeropage.inc"
.include "ser-kernel.inc"
.include "ser-error.inc"
.include "lynx.inc"
.include "zeropage.inc"
.include "ser-kernel.inc"
.include "ser-error.inc"
; ------------------------------------------------------------------------
; Header. Includes jump table
.segment "JUMPTABLE"
.segment "JUMPTABLE"
; Driver signature
.byte $73, $65, $72 ; "ser"
.byte SER_API_VERSION ; Serial API version number
; Driver signature
.byte $73, $65, $72 ; "ser"
.byte SER_API_VERSION ; Serial API version number
; Jump table.
.addr INSTALL
.addr UNINSTALL
.addr OPEN
.addr CLOSE
.addr GET
.addr PUT
.addr STATUS
.addr IOCTL
.addr IRQ
; Jump table.
.addr INSTALL
.addr UNINSTALL
.addr OPEN
.addr CLOSE
.addr GET
.addr PUT
.addr STATUS
.addr IOCTL
.addr IRQ
;----------------------------------------------------------------------------
; Global variables
;
.bss
.bss
TxBuffer: .res 256
RxBuffer: .res 256
RxPtrIn: .res 1
RxPtrOut: .res 1
TxPtrIn: .res 1
TxPtrOut: .res 1
contrl: .res 1
SerialStat: .res 1
TxDone: .res 1
TxBuffer: .res 256
RxBuffer: .res 256
RxPtrIn: .res 1
RxPtrOut: .res 1
TxPtrIn: .res 1
TxPtrOut: .res 1
contrl: .res 1
SerialStat: .res 1
TxDone: .res 1
.code
.code
;----------------------------------------------------------------------------
; INSTALL: Is called after the driver is loaded into memory.
@@ -53,7 +53,7 @@ TxDone: .res 1
; Must return an SER_ERR_xx code in a/x.
INSTALL:
; Set up IRQ vector ?
; Set up IRQ vector ?
;----------------------------------------------------------------------------
; UNINSTALL: Is called before the driver is removed from memory.
@@ -67,11 +67,11 @@ UNINSTALL:
; Must return an SER_ERR_xx code in a/x.
CLOSE:
; Disable interrupts
; Done, return an error code
lda #<SER_ERR_OK
ldx #>SER_ERR_OK
rts
; Disable interrupts
; Done, return an error code
lda #<SER_ERR_OK
ldx #>SER_ERR_OK
rts
;----------------------------------------------------------------------------
; OPEN: A pointer to a ser_params structure is passed in ptr1.
@@ -95,150 +95,150 @@ CLOSE:
;
; Must return an SER_ERR_xx code in a/x.
OPEN:
stz RxPtrIn
stz RxPtrOut
stz TxPtrIn
stz TxPtrOut
OPEN:
stz RxPtrIn
stz RxPtrOut
stz TxPtrIn
stz TxPtrOut
; clock = 8 * 15625
lda #%00011000
sta TIM4CTLA
ldy #SER_PARAMS::BAUDRATE
lda (ptr1),y
; clock = 8 * 15625
lda #%00011000
sta TIM4CTLA
ldy #SER_PARAMS::BAUDRATE
lda (ptr1),y
ldx #1
cmp #SER_BAUD_62500
beq setbaudrate
ldx #1
cmp #SER_BAUD_62500
beq setbaudrate
ldx #2
cmp #SER_BAUD_31250
beq setbaudrate
ldx #2
cmp #SER_BAUD_31250
beq setbaudrate
ldx #12
cmp #SER_BAUD_9600
beq setbaudrate
ldx #12
cmp #SER_BAUD_9600
beq setbaudrate
ldx #25
cmp #SER_BAUD_4800
beq setbaudrate
ldx #25
cmp #SER_BAUD_4800
beq setbaudrate
ldx #51
cmp #SER_BAUD_2400
beq setbaudrate
ldx #51
cmp #SER_BAUD_2400
beq setbaudrate
ldx #103
cmp #SER_BAUD_1200
beq setbaudrate
ldx #103
cmp #SER_BAUD_1200
beq setbaudrate
ldx #207
cmp #SER_BAUD_600
beq setbaudrate
ldx #207
cmp #SER_BAUD_600
beq setbaudrate
; clock = 6 * 15625
ldx #%00011010
stx TIM4CTLA
; clock = 6 * 15625
ldx #%00011010
stx TIM4CTLA
ldx #12
cmp #SER_BAUD_7200
beq setbaudrate
ldx #12
cmp #SER_BAUD_7200
beq setbaudrate
ldx #25
cmp #SER_BAUD_3600
beq setbaudrate
ldx #25
cmp #SER_BAUD_3600
beq setbaudrate
ldx #207
stx TIM4BKUP
ldx #207
stx TIM4BKUP
; clock = 4 * 15625
ldx #%00011100
cmp #SER_BAUD_300
beq setprescaler
; clock = 4 * 15625
ldx #%00011100
cmp #SER_BAUD_300
beq setprescaler
; clock = 6 * 15625
ldx #%00011110
cmp #SER_BAUD_150
beq setprescaler
; clock = 6 * 15625
ldx #%00011110
cmp #SER_BAUD_150
beq setprescaler
; clock = 1 * 15625
ldx #%00011111
stx TIM4CTLA
cmp #SER_BAUD_75
beq baudsuccess
; clock = 1 * 15625
ldx #%00011111
stx TIM4CTLA
cmp #SER_BAUD_75
beq baudsuccess
ldx #141
cmp #SER_BAUD_110
beq setbaudrate
ldx #141
cmp #SER_BAUD_110
beq setbaudrate
; clock = 2 * 15625
ldx #%00011010
stx TIM4CTLA
ldx #68
cmp #SER_BAUD_1800
beq setbaudrate
; clock = 2 * 15625
ldx #%00011010
stx TIM4CTLA
ldx #68
cmp #SER_BAUD_1800
beq setbaudrate
; clock = 6 * 15625
ldx #%00011110
stx TIM4CTLA
ldx #231
cmp #SER_BAUD_134_5
beq setbaudrate
; clock = 6 * 15625
ldx #%00011110
stx TIM4CTLA
ldx #231
cmp #SER_BAUD_134_5
beq setbaudrate
lda #<SER_ERR_BAUD_UNAVAIL
ldx #>SER_ERR_BAUD_UNAVAIL
rts
lda #<SER_ERR_BAUD_UNAVAIL
ldx #>SER_ERR_BAUD_UNAVAIL
rts
setprescaler:
stx TIM4CTLA
bra baudsuccess
stx TIM4CTLA
bra baudsuccess
setbaudrate:
stx TIM4BKUP
stx TIM4BKUP
baudsuccess:
ldx #TxOpenColl|ParEven
stx contrl
ldy #SER_PARAMS::DATABITS ; Databits
lda (ptr1),y
cmp #SER_BITS_8
bne invparameter
ldy #SER_PARAMS::STOPBITS ; Stopbits
lda (ptr1),y
cmp #SER_STOP_1
bne invparameter
ldy #SER_PARAMS::PARITY ; Parity
lda (ptr1),y
cmp #SER_PAR_NONE
beq invparameter
cmp #SER_PAR_MARK
beq checkhs
cmp #SER_PAR_SPACE
bne @L0
ldx #TxOpenColl
stx contrl
bra checkhs
ldx #TxOpenColl|ParEven
stx contrl
ldy #SER_PARAMS::DATABITS ; Databits
lda (ptr1),y
cmp #SER_BITS_8
bne invparameter
ldy #SER_PARAMS::STOPBITS ; Stopbits
lda (ptr1),y
cmp #SER_STOP_1
bne invparameter
ldy #SER_PARAMS::PARITY ; Parity
lda (ptr1),y
cmp #SER_PAR_NONE
beq invparameter
cmp #SER_PAR_MARK
beq checkhs
cmp #SER_PAR_SPACE
bne @L0
ldx #TxOpenColl
stx contrl
bra checkhs
@L0:
ldx #TxParEnable|TxOpenColl|ParEven
stx contrl
cmp #SER_PAR_EVEN
beq checkhs
ldx #TxParEnable|TxOpenColl
stx contrl
ldx #TxParEnable|TxOpenColl|ParEven
stx contrl
cmp #SER_PAR_EVEN
beq checkhs
ldx #TxParEnable|TxOpenColl
stx contrl
checkhs:
ldx contrl
stx SERCTL
ldy #SER_PARAMS::HANDSHAKE ; Handshake
lda (ptr1),y
cmp #SER_HS_NONE
bne invparameter
lda SERDAT
lda contrl
ora #RxIntEnable|ResetErr
sta SERCTL
lda #<SER_ERR_OK
ldx #>SER_ERR_OK
rts
ldx contrl
stx SERCTL
ldy #SER_PARAMS::HANDSHAKE ; Handshake
lda (ptr1),y
cmp #SER_HS_NONE
bne invparameter
lda SERDAT
lda contrl
ora #RxIntEnable|ResetErr
sta SERCTL
lda #<SER_ERR_OK
ldx #>SER_ERR_OK
rts
invparameter:
lda #<SER_ERR_INIT_FAILED
ldx #>SER_ERR_INIT_FAILED
rts
lda #<SER_ERR_INIT_FAILED
ldx #>SER_ERR_INIT_FAILED
rts
;----------------------------------------------------------------------------
; GET: Will fetch a character from the receive buffer and store it into the
@@ -246,64 +246,64 @@ invparameter:
; returned.
GET:
lda RxPtrIn
cmp RxPtrOut
bne GetByte
lda #<SER_ERR_NO_DATA
ldx #>SER_ERR_NO_DATA
rts
lda RxPtrIn
cmp RxPtrOut
bne GetByte
lda #<SER_ERR_NO_DATA
ldx #>SER_ERR_NO_DATA
rts
GetByte:
ldy RxPtrOut
lda RxBuffer,y
inc RxPtrOut
ldx #$00
sta (ptr1,x)
txa ; Return code = 0
rts
ldy RxPtrOut
lda RxBuffer,y
inc RxPtrOut
ldx #$00
sta (ptr1,x)
txa ; Return code = 0
rts
;----------------------------------------------------------------------------
; PUT: Output character in A.
; Must return an SER_ERR_xx code in a/x.
PUT:
tax
lda TxPtrIn
ina
cmp TxPtrOut
bne PutByte
lda #<SER_ERR_OVERFLOW
ldx #>SER_ERR_OVERFLOW
rts
tax
lda TxPtrIn
ina
cmp TxPtrOut
bne PutByte
lda #<SER_ERR_OVERFLOW
ldx #>SER_ERR_OVERFLOW
rts
PutByte:
ldy TxPtrIn
txa
sta TxBuffer,y
inc TxPtrIn
ldy TxPtrIn
txa
sta TxBuffer,y
inc TxPtrIn
bit TxDone
bmi @L1
bit TxDone
bmi @L1
php
sei
lda contrl
ora #TxIntEnable|ResetErr
sta SERCTL ; Allow TX-IRQ to hang RX-IRQ
sta TxDone
lda contrl
ora #TxIntEnable|ResetErr
sta SERCTL ; Allow TX-IRQ to hang RX-IRQ
sta TxDone
plp
@L1:
lda #<SER_ERR_OK
tax
rts
lda #<SER_ERR_OK
tax
rts
;----------------------------------------------------------------------------
; STATUS: Return the status in the variable pointed to by ptr1.
; Must return an SER_ERR_xx code in a/x.
STATUS:
ldy SerialStat
ldx #$00
sta (ptr1,x)
txa ; Return code = 0
rts
ldy SerialStat
ldx #$00
sta (ptr1,x)
txa ; Return code = 0
rts
;----------------------------------------------------------------------------
; IOCTL: Driver defined entry point. The wrapper will pass a pointer to ioctl
@@ -311,9 +311,9 @@ STATUS:
; Must return an SER_ERR_xx code in a/x.
IOCTL:
lda #<SER_ERR_INV_IOCTL
ldx #>SER_ERR_INV_IOCTL
rts
lda #<SER_ERR_INV_IOCTL
ldx #>SER_ERR_INV_IOCTL
rts
;----------------------------------------------------------------------------
; IRQ: Called from the builtin runtime IRQ handler as a subroutine. All
@@ -325,84 +325,84 @@ IOCTL:
; Due to this bug you have to disable the interrupt before clearing it.
IRQ:
lda INTSET ; Poll all pending interrupts
and #SERIAL_INTERRUPT
bne @L0
clc
rts
lda INTSET ; Poll all pending interrupts
and #SERIAL_INTERRUPT
bne @L0
clc
rts
@L0:
bit TxDone
bmi @tx_irq ; Transmit in progress
ldx SERDAT
lda SERCTL
and #RxParityErr|RxOverrun|RxFrameErr|RxBreak
beq @rx_irq
tsb SerialStat ; Save error condition
bit #RxBreak
beq @noBreak
stz TxPtrIn ; Break received - drop buffers
stz TxPtrOut
stz RxPtrIn
stz RxPtrOut
bit TxDone
bmi @tx_irq ; Transmit in progress
ldx SERDAT
lda SERCTL
and #RxParityErr|RxOverrun|RxFrameErr|RxBreak
beq @rx_irq
tsb SerialStat ; Save error condition
bit #RxBreak
beq @noBreak
stz TxPtrIn ; Break received - drop buffers
stz TxPtrOut
stz RxPtrIn
stz RxPtrOut
@noBreak:
lda contrl
ora #RxIntEnable|ResetErr
sta SERCTL
lda #$10
sta INTRST
bra @IRQexit
lda contrl
ora #RxIntEnable|ResetErr
sta SERCTL
lda #$10
sta INTRST
bra @IRQexit
@rx_irq:
lda contrl
ora #RxIntEnable|ResetErr
sta SERCTL
lda contrl
ora #RxIntEnable|ResetErr
sta SERCTL
txa
ldx RxPtrIn
sta RxBuffer,x
ldx RxPtrIn
sta RxBuffer,x
txa
inx
@cont0:
cpx RxPtrOut
beq @1
stx RxPtrIn
lda #SERIAL_INTERRUPT
sta INTRST
bra @IRQexit
cpx RxPtrOut
beq @1
stx RxPtrIn
lda #SERIAL_INTERRUPT
sta INTRST
bra @IRQexit
@1:
sta RxPtrIn
lda #$80
tsb SerialStat
sta RxPtrIn
lda #$80
tsb SerialStat
@tx_irq:
ldx TxPtrOut ; Has all bytes been sent?
cpx TxPtrIn
beq @allSent
ldx TxPtrOut ; Has all bytes been sent?
cpx TxPtrIn
beq @allSent
lda TxBuffer,x ; Send next byte
sta SERDAT
inc TxPtrOut
lda TxBuffer,x ; Send next byte
sta SERDAT
inc TxPtrOut
@exit1:
lda contrl
ora #TxIntEnable|ResetErr
sta SERCTL
lda #SERIAL_INTERRUPT
sta INTRST
bra @IRQexit
lda contrl
ora #TxIntEnable|ResetErr
sta SERCTL
lda #SERIAL_INTERRUPT
sta INTRST
bra @IRQexit
@allSent:
lda SERCTL ; All bytes sent
bit #TxEmpty
beq @exit1
bvs @exit1
stz TxDone
lda contrl
ora #RxIntEnable|ResetErr
sta SERCTL
lda SERCTL ; All bytes sent
bit #TxEmpty
beq @exit1
bvs @exit1
stz TxDone
lda contrl
ora #RxIntEnable|ResetErr
sta SERCTL
lda #SERIAL_INTERRUPT
sta INTRST
lda #SERIAL_INTERRUPT
sta INTRST
@IRQexit:
clc
clc
rts

File diff suppressed because it is too large Load Diff

View File

@@ -2,7 +2,7 @@
; Target-specific black & white values for use by the target-shared TGI kernel
;
.include "tgi-kernel.inc"
.include "tgi-kernel.inc"
.export tgi_color_black:zp = $00
.export tgi_color_white:zp = $0F
.export tgi_color_black:zp = $00
.export tgi_color_white:zp = $0F

View File

@@ -6,8 +6,8 @@
; const void tgi_static_stddrv[];
;
.export _tgi_static_stddrv
.import _lynx_160_102_16_tgi
.export _tgi_static_stddrv
.import _lynx_160_102_16_tgi
.rodata

View File

@@ -6,8 +6,8 @@
; const char tgi_stddrv[];
;
.export _tgi_stddrv
.export _tgi_stddrv
.rodata
_tgi_stddrv: .asciiz "lynx-160-102-16.tgi"
_tgi_stddrv: .asciiz "lynx-160-102-16.tgi"

View File

@@ -8,9 +8,9 @@
.proc _toascii
; X must be zero on return
ldx #0
ldx #0
; Done!
rts
rts
.endproc

View File

@@ -1,7 +1,7 @@
.include "lynx.inc"
.include "extzp.inc"
.interruptor _UpLoaderIRQ
.export __UPLOADER__: absolute = 1
.include "lynx.inc"
.include "extzp.inc"
.interruptor _UpLoaderIRQ
.export __UPLOADER__: absolute = 1
load_len=_FileDestAddr
load_ptr=_FileFileLen
@@ -10,12 +10,12 @@ load_ptr2=_FileCurrBlock
.segment "UPCODE"
ComLynxReadAndExec:
ldy #4
ldy #4
loop0:
jsr read_byte
sta load_len-1,y
dey
bne loop0 ; get destination and length
jsr read_byte
sta load_len-1,y
dey
bne loop0 ; get destination and length
tax ; lowbyte of length
lda load_ptr
@@ -24,20 +24,20 @@ loop0:
sta load_ptr2+1
loop1:
inx
inx
bne cont1
inc load_len+1
bne cont1
jmp (load_ptr)
cont1:
jsr read_byte
jsr read_byte
sta (load_ptr2),y
sta PALETTE ; feedback ;-)
iny
bne loop1
inc load_ptr2+1
bra loop1
bne loop1
inc load_ptr2+1
bra loop1
read_byte:
bit SERCTL
@@ -46,22 +46,22 @@ read_byte:
rts
_UpLoaderIRQ:
lda INTSET
and #$10
bne @L0
clc
rts
lda INTSET
and #$10
bne @L0
clc
rts
@L0:
lda SERDAT ; wait for the start sequence
bit flag ; already seen $81 ?
bpl again ; >= 0 => no
cmp #$50 ; "P" ?
bne again ; not correct, so clear flag
sei
sei
jmp ComLynxReadAndExec
again:
stz flag
stz flag
cmp #$81
bne exit
sta flag
@@ -69,11 +69,11 @@ again:
; last action : clear interrupt
;
exit:
clc
clc
rts
.segment "UPDATA"
flag:
.byte 0
.byte 0