Merge remote-tracking branch 'origin/master' into coniopeek
This commit is contained in:
@@ -6,7 +6,6 @@
|
||||
|
||||
.export screensize
|
||||
.import SCREEN
|
||||
|
||||
|
||||
screensize = SCREEN
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 28.09.1998
|
||||
;
|
||||
; Banking routines for the 610.
|
||||
; Banking routines for the 510.
|
||||
;
|
||||
|
||||
.export set_bank, sys_bank, restore_bank
|
||||
@@ -37,5 +37,3 @@
|
||||
pla
|
||||
rts
|
||||
.endproc
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 27.09.1998
|
||||
;
|
||||
; void set_brk (unsigned Addr);
|
||||
; void __fastcall__ set_brk (unsigned Addr);
|
||||
; void reset_brk (void);
|
||||
;
|
||||
|
||||
|
||||
24
libsrc/cbm510/cpeekcolor.s
Normal file
24
libsrc/cbm510/cpeekcolor.s
Normal file
@@ -0,0 +1,24 @@
|
||||
;
|
||||
; 2016-02-28, Groepaz
|
||||
; 2017-06-19, Greg King
|
||||
;
|
||||
; unsigned char cpeekcolor (void);
|
||||
;
|
||||
|
||||
.export _cpeekcolor
|
||||
|
||||
.import CURS_X: zp, CRAM_PTR: zp
|
||||
|
||||
.include "cbm510.inc"
|
||||
|
||||
|
||||
_cpeekcolor:
|
||||
ldx IndReg
|
||||
lda #$0F
|
||||
sta IndReg
|
||||
ldy CURS_X
|
||||
lda (CRAM_PTR),y ; get color
|
||||
stx IndReg
|
||||
and #$0F
|
||||
ldx #>$0000
|
||||
rts
|
||||
@@ -8,7 +8,7 @@
|
||||
.export _cputcxy, _cputc, cputdirect, putchar
|
||||
.export newline, plot
|
||||
|
||||
.import popa, _gotoxy
|
||||
.import gotoxy
|
||||
.import __VIDRAM_START__
|
||||
.import CURS_X: zp, CURS_Y: zp, CHARCOLOR: zp, RVS: zp
|
||||
.import SCREEN_PTR: zp, CRAM_PTR: zp
|
||||
@@ -22,8 +22,7 @@
|
||||
|
||||
_cputcxy:
|
||||
pha ; Save C
|
||||
jsr popa ; Get Y
|
||||
jsr _gotoxy ; Set cursor, drop x
|
||||
jsr gotoxy ; Set cursor, drop x and y
|
||||
pla ; Restore C
|
||||
|
||||
; Plot a character - also used as internal function
|
||||
@@ -66,10 +65,9 @@ L3: sty CURS_X
|
||||
; Handle character if high bit set
|
||||
|
||||
L10: and #$7F
|
||||
cmp #$7E ; PI?
|
||||
cmp #$7F ; PI?
|
||||
bne L11
|
||||
lda #$5E ; Load screen code for PI
|
||||
bne cputdirect
|
||||
L11: ora #$40
|
||||
bne cputdirect ; Branch always
|
||||
|
||||
|
||||
16
libsrc/cbm510/doesclrscr.s
Normal file
16
libsrc/cbm510/doesclrscr.s
Normal file
@@ -0,0 +1,16 @@
|
||||
;
|
||||
; 2016-06, Christian Groessler
|
||||
; 2017-07-05, Greg King
|
||||
;
|
||||
; unsigned char doesclrscrafterexit (void);
|
||||
;
|
||||
; Returns 0/1 if, after program termination, the screen isn't/is cleared.
|
||||
;
|
||||
|
||||
.import return1
|
||||
|
||||
; cc65's CBM510 programs switch to a display screen in the program RAM bank;
|
||||
; then, they switch back to the system bank when they exit.
|
||||
; The screen is cleared.
|
||||
|
||||
.export _doesclrscrafterexit := return1
|
||||
@@ -1,43 +1,45 @@
|
||||
;
|
||||
; Stefan Haubenthal, 2009-07-27
|
||||
; Ullrich von Bassewitz, 2009-09-24
|
||||
; 2009-07-27, Stefan Haubenthal
|
||||
; 2009-09-24, Ullrich von Bassewitz
|
||||
; 2018-08-18, Oliver Schmidt
|
||||
; 2018-08-19, Greg King
|
||||
;
|
||||
; time_t _systime (void);
|
||||
; /* Similar to time(), but:
|
||||
; ** - Is not ISO C
|
||||
; ** - Does not take the additional pointer
|
||||
; ** - Does not set errno when returning -1
|
||||
; */
|
||||
; int __fastcall__ clock_gettime (clockid_t clk_id, struct timespec *tp);
|
||||
;
|
||||
|
||||
.include "time.inc"
|
||||
.include "cbm510.inc"
|
||||
.include "extzp.inc"
|
||||
|
||||
.import pushax, pusheax, tosmul0ax, steaxspidx, incsp1
|
||||
.import sys_bank, restore_bank
|
||||
.importzp tmp1, tmp2
|
||||
.import TM, load_tenth
|
||||
.importzp sreg, tmp1, tmp2
|
||||
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
.code
|
||||
|
||||
.proc __systime
|
||||
.proc _clock_gettime
|
||||
|
||||
; Switch to the system bank
|
||||
jsr pushax
|
||||
jsr pushax
|
||||
|
||||
jsr sys_bank
|
||||
|
||||
; Read the clock
|
||||
|
||||
ldy #CIA::TODHR
|
||||
lda (cia2),y
|
||||
bpl AM
|
||||
and #%01111111
|
||||
sed
|
||||
tax ; Save PM flag
|
||||
and #%01111111
|
||||
cmp #$12 ; 12 AM/PM
|
||||
bcc @L1
|
||||
sbc #$12
|
||||
@L1: inx ; Get PM flag
|
||||
bpl @L2
|
||||
clc
|
||||
adc #$12
|
||||
cld
|
||||
AM: jsr BCD2dec
|
||||
@L2: cld
|
||||
jsr BCD2dec
|
||||
sta TM + tm::tm_hour
|
||||
ldy #CIA::TODMIN
|
||||
lda (cia2),y
|
||||
@@ -48,17 +50,28 @@ AM: jsr BCD2dec
|
||||
jsr BCD2dec
|
||||
sta TM + tm::tm_sec
|
||||
ldy #CIA::TOD10
|
||||
lda (cia2),y ; Dummy read to unfreeze
|
||||
|
||||
; Restore the bank
|
||||
|
||||
lda (cia2),y
|
||||
jsr restore_bank
|
||||
|
||||
; Convert to a time
|
||||
|
||||
pha
|
||||
lda #<TM
|
||||
ldx #>TM
|
||||
jmp _mktime
|
||||
jsr _mktime
|
||||
|
||||
ldy #timespec::tv_sec
|
||||
jsr steaxspidx ; Pops address pushed by 2. pushax
|
||||
|
||||
jsr load_tenth
|
||||
jsr pusheax
|
||||
pla
|
||||
ldx #>$0000
|
||||
jsr tosmul0ax
|
||||
|
||||
ldy #timespec::tv_nsec
|
||||
jsr steaxspidx ; Pops address pushed by 1. pushax
|
||||
|
||||
lda #$00
|
||||
tax
|
||||
jmp incsp1
|
||||
|
||||
.endproc
|
||||
|
||||
@@ -81,18 +94,3 @@ AM: jsr BCD2dec
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; TM struct with date set to 1970-01-01
|
||||
.data
|
||||
|
||||
TM: .word 0 ; tm_sec
|
||||
.word 0 ; tm_min
|
||||
.word 0 ; tm_hour
|
||||
.word 1 ; tm_mday
|
||||
.word 0 ; tm_mon
|
||||
.word 70 ; tm_year
|
||||
.word 0 ; tm_wday
|
||||
.word 0 ; tm_yday
|
||||
.word 0 ; tm_isdst
|
||||
|
||||
@@ -30,24 +30,12 @@
|
||||
|
||||
.addr $0000
|
||||
|
||||
; 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
|
||||
|
||||
; Jump table.
|
||||
|
||||
.addr INSTALL
|
||||
.addr UNINSTALL
|
||||
.addr COUNT
|
||||
.addr READ
|
||||
.addr 0 ; IRQ entry unused
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Constants
|
||||
@@ -105,7 +93,7 @@ READ: ldx #$0F ; Switch to the system bank
|
||||
lda (cia2),y ; Read joystick inputs
|
||||
sta tmp1
|
||||
|
||||
; Get the fire bits
|
||||
; Get the push button bits
|
||||
|
||||
ldy #CIA::PRA
|
||||
lda (cia2),y
|
||||
@@ -115,12 +103,12 @@ READ: ldx #$0F ; Switch to the system bank
|
||||
cpx #$00 ; Joystick 0?
|
||||
bne @L1 ; Jump if no
|
||||
|
||||
; Joystick 1, fire is in bit 6, direction in bit 0-3
|
||||
; Joystick 1, push button is in bit 6, direction in bit 0-3
|
||||
|
||||
asl a
|
||||
jmp @L2
|
||||
|
||||
; Joystick 2, fire is in bit 7, direction in bit 5-7
|
||||
; Joystick 2, push button is in bit 7, direction in bit 5-7
|
||||
|
||||
@L1: ldx #$00 ; High byte of return value
|
||||
lsr tmp1
|
||||
@@ -128,9 +116,9 @@ READ: ldx #$0F ; Switch to the system bank
|
||||
lsr tmp1
|
||||
lsr tmp1
|
||||
|
||||
; Mask the relavant bits, get the fire bit
|
||||
; Mask the relavant bits, get the push button bit
|
||||
|
||||
@L2: asl a ; Fire bit into carry
|
||||
@L2: asl a ; push button bit into carry
|
||||
lda tmp1
|
||||
and #$0F
|
||||
bcc @L3
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 2003-12-20
|
||||
;
|
||||
; CBM610 kernal functions
|
||||
; CBM510 kernal functions
|
||||
;
|
||||
|
||||
.include "cbm_kernal.inc"
|
||||
|
||||
.export CINT
|
||||
.export IOINIT
|
||||
.export RAMTAS
|
||||
.export RESTOR
|
||||
.export VECTOR
|
||||
.export SETMSG
|
||||
@@ -27,57 +28,12 @@
|
||||
.export CKOUT
|
||||
.export CLRCH
|
||||
.export BASIN
|
||||
.export CHRIN
|
||||
.export BSOUT
|
||||
.export CHROUT
|
||||
.export LOAD
|
||||
.export SAVE
|
||||
.export STOP
|
||||
.export GETIN
|
||||
.export CLALL
|
||||
.export PLOT
|
||||
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
; All functions are available in the kernal jump table. Functions having
|
||||
; replacements (usually short ones where the overhead of the cross bank call
|
||||
; is not worth the trouble) are commented out.
|
||||
|
||||
CINT = $FF81
|
||||
IOINIT = $FF84
|
||||
RAMTAS = $FF87
|
||||
RESTOR = $FF8A
|
||||
VECTOR = $FF8D
|
||||
SETMSG = $FF90
|
||||
SECOND = $FF93
|
||||
TKSA = $FF96
|
||||
MEMTOP = $FF99
|
||||
MEMBOT = $FF9C
|
||||
SCNKEY = $FF9F
|
||||
SETTMO = $FFA2
|
||||
ACPTR = $FFA5
|
||||
CIOUT = $FFA8
|
||||
UNTLK = $FFAB
|
||||
UNLSN = $FFAE
|
||||
LISTEN = $FFB1
|
||||
TALK = $FFB4
|
||||
;READST = $FFB7
|
||||
SETLFS = $FFBA
|
||||
;SETNAM = $FFBD
|
||||
;OPEN = $FFC0
|
||||
;CLOSE = $FFC3
|
||||
CHKIN = $FFC6
|
||||
CKOUT = $FFC9
|
||||
CLRCH = $FFCC
|
||||
BASIN = $FFCF
|
||||
BSOUT = $FFD2
|
||||
LOAD = $FFD5
|
||||
SAVE = $FFD8
|
||||
;SETTIM = $FFDB
|
||||
;RDTIM = $FFDE
|
||||
STOP = $FFE1
|
||||
GETIN = $FFE4
|
||||
CLALL = $FFE7
|
||||
;UDTIM = $FFEA
|
||||
;SCREEN = $FFED
|
||||
PLOT = $FFF0
|
||||
;IOBASE = $FFF3
|
||||
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
;
|
||||
; OPEN kernal call.
|
||||
;
|
||||
; NOTE: The OPEN system call in the CBM610 kernal is different from the
|
||||
; NOTE: The OPEN system call in the CBM610 kernal is different from the
|
||||
; standard. It evaluates the carry flag and does a normal open if carry clear
|
||||
; and some strange things (output sa 15 + name on IEC) if carry set. To be
|
||||
; compatible with our CBM file stuff, we have to clear the carry before
|
||||
; compatible with our CBM file stuff, we have to clear the carry before
|
||||
; calling the real OPEN.
|
||||
|
||||
.export OPEN
|
||||
@@ -18,5 +18,3 @@
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
;
|
||||
; udtim routine for the 610. We will not check for the stop key here, since
|
||||
; C programs will not use it.
|
||||
;
|
||||
;
|
||||
|
||||
.export UDTIM
|
||||
.import time: zp
|
||||
|
||||
@@ -35,10 +35,10 @@ 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,
|
||||
; Get possible command-line arguments. Goes into the special ONCE segment,
|
||||
; which may be reused after the startup code is run.
|
||||
;
|
||||
.segment "INIT"
|
||||
.segment "ONCE"
|
||||
|
||||
initmainargs:
|
||||
|
||||
@@ -144,7 +144,7 @@ done: lda #<argv
|
||||
stx __argv + 1
|
||||
rts
|
||||
|
||||
.segment "INITBSS"
|
||||
.segment "INIT"
|
||||
|
||||
term: .res 1
|
||||
name: .res NAME_LEN + 1
|
||||
|
||||
@@ -21,17 +21,17 @@
|
||||
|
||||
; Sprite definitions. The first value can be changed to adjust the number
|
||||
; of the sprite used for the mouse. All others depend on that value.
|
||||
MOUSE_SPR = 0 ; Sprite used for the mouse
|
||||
MOUSE_SPR_MEM = $F400 ; Memory location
|
||||
MOUSE_SPR_MASK = $01 .shl MOUSE_SPR ; Positive mask
|
||||
MOUSE_SPR_NMASK = .lobyte(.not MOUSE_SPR_MASK) ; Negative mask
|
||||
VIC_SPR_X = (VIC_SPR0_X + 2*MOUSE_SPR) ; Sprite X register
|
||||
VIC_SPR_Y = (VIC_SPR0_Y + 2*MOUSE_SPR) ; Sprite Y register
|
||||
MOUSE_SPR = 0 ; Sprite used for the mouse
|
||||
MOUSE_SPR_MEM = $F400 ; Memory location
|
||||
MOUSE_SPR_MASK = $01 .shl MOUSE_SPR ; Positive mask
|
||||
MOUSE_SPR_NMASK = .lobyte(.bitnot MOUSE_SPR_MASK) ; Negative mask
|
||||
VIC_SPR_X = (VIC_SPR0_X + 2*MOUSE_SPR) ; Sprite X register
|
||||
VIC_SPR_Y = (VIC_SPR0_Y + 2*MOUSE_SPR) ; Sprite Y register
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Initialize the mouse sprite.
|
||||
|
||||
.segment "INIT"
|
||||
.segment "ONCE"
|
||||
|
||||
initmcb:
|
||||
|
||||
|
||||
0
libsrc/cbm510/pencalib.c
Executable file → Normal file
0
libsrc/cbm510/pencalib.c
Executable file → Normal file
@@ -46,15 +46,15 @@
|
||||
|
||||
; Jump table
|
||||
|
||||
.word INSTALL
|
||||
.word UNINSTALL
|
||||
.word OPEN
|
||||
.word CLOSE
|
||||
.word GET
|
||||
.word PUT
|
||||
.word STATUS
|
||||
.word IOCTL
|
||||
.word IRQ
|
||||
.word SER_INSTALL
|
||||
.word SER_UNINSTALL
|
||||
.word SER_OPEN
|
||||
.word SER_CLOSE
|
||||
.word SER_GET
|
||||
.word SER_PUT
|
||||
.word SER_STATUS
|
||||
.word SER_IOCTL
|
||||
.word SER_IRQ
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
;
|
||||
@@ -122,24 +122,24 @@ ParityTable:
|
||||
.code
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; INSTALL routine. Is called after the driver is loaded into memory. If
|
||||
; SER_INSTALL routine. Is called after the driver is loaded into memory. If
|
||||
; possible, check if the hardware is present.
|
||||
; Must return an SER_ERR_xx code in a/x.
|
||||
;
|
||||
; Since we don't have to manage the IRQ vector on the Plus/4, this is actually
|
||||
; the same as:
|
||||
;
|
||||
; UNINSTALL routine. Is called before the driver is removed from memory.
|
||||
; SER_UNINSTALL routine. Is called before the driver is removed from memory.
|
||||
; Must return an SER_ERR_xx code in a/x.
|
||||
; and:
|
||||
;
|
||||
; CLOSE: Close the port, disable interrupts and flush the buffer. Called
|
||||
; SER_CLOSE: Close the port, disable interrupts and flush the buffer. Called
|
||||
; without parameters. Must return an error code in a/x.
|
||||
;
|
||||
|
||||
INSTALL:
|
||||
UNINSTALL:
|
||||
CLOSE:
|
||||
SER_INSTALL:
|
||||
SER_UNINSTALL:
|
||||
SER_CLOSE:
|
||||
|
||||
; Deactivate DTR and disable 6551 interrupts
|
||||
|
||||
@@ -156,7 +156,7 @@ CLOSE:
|
||||
; PARAMS routine. A pointer to a ser_params structure is passed in ptr1.
|
||||
; Must return an SER_ERR_xx code in a/x.
|
||||
|
||||
OPEN:
|
||||
SER_OPEN:
|
||||
|
||||
; Check if the handshake setting is valid
|
||||
|
||||
@@ -236,12 +236,13 @@ InvBaud:
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; GET: Will fetch a character from the receive buffer and store it into the
|
||||
; SER_GET: Will fetch a character from the receive buffer and store it into the
|
||||
; variable pointer to by ptr1. If no data is available, SER_ERR_NO_DATA is
|
||||
; return.
|
||||
;
|
||||
|
||||
GET: ldx SendFreeCnt ; Send data if necessary
|
||||
SER_GET:
|
||||
ldx SendFreeCnt ; Send data if necessary
|
||||
inx ; X == $FF?
|
||||
beq @L1
|
||||
lda #$00
|
||||
@@ -280,11 +281,11 @@ GET: ldx SendFreeCnt ; Send data if necessary
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; PUT: Output character in A.
|
||||
; SER_PUT: Output character in A.
|
||||
; Must return an error code in a/x.
|
||||
;
|
||||
|
||||
PUT:
|
||||
SER_PUT:
|
||||
|
||||
; Try to send
|
||||
|
||||
@@ -314,11 +315,12 @@ PUT:
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; STATUS: Return the status in the variable pointed to by ptr1.
|
||||
; SER_STATUS: Return the status in the variable pointed to by ptr1.
|
||||
; Must return an error code in a/x.
|
||||
;
|
||||
|
||||
STATUS: lda #$0F
|
||||
SER_STATUS:
|
||||
lda #$0F
|
||||
sta IndReg
|
||||
ldy #ACIA::STATUS
|
||||
lda (acia),y
|
||||
@@ -330,23 +332,25 @@ STATUS: lda #$0F
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; IOCTL: Driver defined entry point. The wrapper will pass a pointer to ioctl
|
||||
; SER_IOCTL: Driver defined entry point. The wrapper will pass a pointer to ioctl
|
||||
; specific data in ptr1, and the ioctl code in A.
|
||||
; Must return an error code in a/x.
|
||||
;
|
||||
|
||||
IOCTL: lda #<SER_ERR_INV_IOCTL ; We don't support ioclts for now
|
||||
SER_IOCTL:
|
||||
lda #<SER_ERR_INV_IOCTL ; We don't support ioclts for now
|
||||
ldx #>SER_ERR_INV_IOCTL
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; IRQ: Called from the builtin runtime IRQ handler as a subroutine. All
|
||||
; SER_IRQ: Called from the builtin runtime IRQ handler as a subroutine. All
|
||||
; registers are already save, no parameters are passed, but the carry flag
|
||||
; is clear on entry. The routine must return with carry set if the interrupt
|
||||
; was handled, otherwise with carry clear.
|
||||
;
|
||||
|
||||
IRQ: lda #$0F
|
||||
SER_IRQ:
|
||||
lda #$0F
|
||||
sta IndReg ; Switch to the system bank
|
||||
ldy #ACIA::STATUS
|
||||
lda (acia),y ; Check ACIA status for receive interrupt
|
||||
@@ -435,4 +439,3 @@ write: pha
|
||||
lda ExecReg
|
||||
sta IndReg
|
||||
rts
|
||||
|
||||
|
||||
97
libsrc/cbm510/settime.s
Normal file
97
libsrc/cbm510/settime.s
Normal file
@@ -0,0 +1,97 @@
|
||||
;
|
||||
; 2018-08-18, Oliver Schmidt
|
||||
; 2018-08-19, Greg King
|
||||
;
|
||||
; int __fastcall__ clock_settime (clockid_t clk_id, const struct timespec *tp);
|
||||
;
|
||||
|
||||
.include "time.inc"
|
||||
.include "cbm510.inc"
|
||||
.include "extzp.inc"
|
||||
|
||||
.importzp sreg, ptr1
|
||||
.import pushax, pusheax, ldax0sp, ldeaxidx
|
||||
.import sys_bank, restore_bank
|
||||
.import tosdiveax, incsp3, return0
|
||||
.import TM, load_tenth
|
||||
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
.code
|
||||
|
||||
.proc _clock_settime
|
||||
|
||||
jsr pushax
|
||||
|
||||
.assert timespec::tv_sec = 0, error
|
||||
jsr _localtime
|
||||
sta ptr1
|
||||
stx ptr1+1
|
||||
ldy #.sizeof(tm)-1
|
||||
@L1: lda (ptr1),y
|
||||
sta TM,y
|
||||
dey
|
||||
bpl @L1
|
||||
|
||||
jsr sys_bank
|
||||
lda TM + tm::tm_hour
|
||||
jsr dec2BCD
|
||||
tax ; Force flags
|
||||
bne @L2
|
||||
lda #$92 ; 12 AM
|
||||
bne @L3
|
||||
@L2: cmp #$13 ; 1 PM
|
||||
bcc @L3
|
||||
sed
|
||||
sbc #$12
|
||||
cld
|
||||
ora #%10000000
|
||||
@L3: ldy #CIA::TODHR
|
||||
sta (cia2),y
|
||||
lda TM + tm::tm_min
|
||||
jsr dec2BCD
|
||||
ldy #CIA::TODMIN
|
||||
sta (cia2),y
|
||||
lda TM + tm::tm_sec
|
||||
jsr dec2BCD
|
||||
ldy #CIA::TODSEC
|
||||
sta (cia2),y
|
||||
jsr restore_bank
|
||||
|
||||
jsr ldax0sp
|
||||
ldy #3+timespec::tv_nsec
|
||||
jsr ldeaxidx
|
||||
jsr pusheax
|
||||
jsr load_tenth
|
||||
jsr tosdiveax
|
||||
|
||||
jsr sys_bank
|
||||
ldy #CIA::TOD10
|
||||
sta (cia2),y
|
||||
jsr restore_bank
|
||||
|
||||
lda #$00
|
||||
tax
|
||||
jmp incsp3
|
||||
|
||||
.endproc
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; Just sum up the value in BCD mode.
|
||||
; http://forum.6502.org/viewtopic.php?p=7629#p7629
|
||||
|
||||
.proc dec2BCD
|
||||
|
||||
tax
|
||||
dex
|
||||
bmi @L9
|
||||
lda #0
|
||||
clc
|
||||
sed
|
||||
@L1: adc #1
|
||||
dex
|
||||
bpl @L1
|
||||
cld
|
||||
@L9: rts
|
||||
|
||||
.endproc
|
||||
41
libsrc/cbm510/tmcommon.s
Normal file
41
libsrc/cbm510/tmcommon.s
Normal file
@@ -0,0 +1,41 @@
|
||||
;
|
||||
; Oliver Schmidt, 16.8.2018
|
||||
;
|
||||
; Common stuff for the clock routines
|
||||
;
|
||||
|
||||
.include "cbm510.inc"
|
||||
|
||||
.export TM, load_tenth
|
||||
|
||||
.importzp sreg
|
||||
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
.code
|
||||
|
||||
.proc load_tenth
|
||||
|
||||
lda #<(100 * 1000 * 1000 / $10000)
|
||||
ldx #>(100 * 1000 * 1000 / $10000)
|
||||
sta sreg
|
||||
stx sreg+1
|
||||
lda #<(100 * 1000 * 1000)
|
||||
ldx #>(100 * 1000 * 1000)
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; TM struct with date set to 1970-01-01
|
||||
.data
|
||||
|
||||
TM: .word 0 ; tm_sec
|
||||
.word 0 ; tm_min
|
||||
.word 0 ; tm_hour
|
||||
.word 1 ; tm_mday
|
||||
.word 0 ; tm_mon
|
||||
.word 70 ; tm_year
|
||||
.word 0 ; tm_wday
|
||||
.word 0 ; tm_yday
|
||||
.word 0 ; tm_isdst
|
||||
28
libsrc/cbm510/waitvsync.s
Normal file
28
libsrc/cbm510/waitvsync.s
Normal file
@@ -0,0 +1,28 @@
|
||||
;
|
||||
; Written by Groepaz <groepaz@gmx.net>
|
||||
;
|
||||
; void waitvsync (void);
|
||||
;
|
||||
|
||||
.export _waitvsync
|
||||
.import PALFLAG
|
||||
.import sys_bank, restore_bank
|
||||
|
||||
.importzp vic
|
||||
|
||||
.include "cbm510.inc"
|
||||
|
||||
_waitvsync:
|
||||
jsr sys_bank ; Switch to the system bank
|
||||
sei
|
||||
|
||||
ldy #VIC_CTRL1
|
||||
@l1:
|
||||
lda (vic),y
|
||||
bpl @l1
|
||||
@l2:
|
||||
lda (vic),y
|
||||
bmi @l2
|
||||
|
||||
cli
|
||||
jmp restore_bank
|
||||
Reference in New Issue
Block a user