Merge remote-tracking branch 'origin/master' into coniopeek

This commit is contained in:
mrdudz
2022-07-24 03:24:45 +02:00
2250 changed files with 195541 additions and 36938 deletions

View File

@@ -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);
;
@@ -55,7 +55,7 @@ uservec: jmp $FFFF ; Patched at runtime
; Break handler, called if a break occurs.
; Break handler, called if a break occurs.
.proc brk_handler
@@ -91,4 +91,3 @@ uservec: jmp $FFFF ; Patched at runtime
.endproc

View File

@@ -7,6 +7,7 @@
.export _cgetc
.import cursor
.include "cbm_kernal.inc"
.include "plus4.inc"
; --------------------------------------------------------------------------
@@ -59,12 +60,14 @@ L2: sta ENABLE_ROM ; Bank in the ROM
.constructor initkbd
.destructor donekbd
.segment "INIT" ; Special init code segment may get overwritten
.segment "ONCE" ; Special init code segment may get overwritten
.proc initkbd
ldy #15
ldy #7
@L1: lda fnkeys,y
sta FKEY_SPACE+8,y
lda #$01 ; Lower 8 places are all $01
sta FKEY_SPACE,y
dey
bpl @L1
@@ -72,6 +75,8 @@ L2: sta ENABLE_ROM ; Bank in the ROM
.endproc
fnkeys: .byte 133, 137, 134, 138, 135, 139, 136, 140
.segment "LOWCODE" ; Accesses the ROM - must go into low mem
@@ -87,11 +92,3 @@ L2: sta ENABLE_ROM ; Bank in the ROM
rts
.endproc
; Function key table, readonly
.rodata
fnkeys: .byte $01, $01, $01, $01, $01, $01, $01, $01
.byte 133, 137, 134, 138, 135, 139, 136, 140

View File

@@ -6,6 +6,7 @@
.export _clrscr
.include "cbm_kernal.inc"
.include "plus4.inc"
.segment "LOWCODE" ; Must go into low memory
@@ -16,9 +17,3 @@
sta ENABLE_RAM ; Switch back to RAM
rts ; Return to caller
.endproc

View File

@@ -7,7 +7,7 @@
.export _cputcxy, _cputc, cputdirect, putchar
.export newline, plot
.import popa, _gotoxy
.import gotoxy
.import PLOT
.include "plus4.inc"
@@ -15,8 +15,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
@@ -75,10 +74,9 @@ L5: inc CURS_Y
; 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

View File

@@ -9,7 +9,7 @@
.import callirq_y, initlib, donelib
.import callmain, zerobss
.import __INTERRUPTOR_COUNT__
.import __RAM_START__, __RAM_SIZE__ ; Linker generated
.import __MAIN_START__, __MAIN_SIZE__ ; Linker generated
.import __STACKSIZE__ ; Linker generated
.importzp ST
@@ -50,12 +50,12 @@ L1: lda sp,x
; of the usable RAM.
tsx
stx spsave ; save system stk ptr
stx spsave ; Save system stk ptr
lda #<(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
lda #<(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__)
ldx #>(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__)
sta sp
lda #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
sta sp+1
stx sp+1
; Set up the IRQ vector in the banked RAM; and, switch off the ROM.
@@ -195,8 +195,6 @@ spsave: .res 1
irqcount: .byte 0
.segment "INITBSS"
.segment "INIT"
zpsave: .res zpspace

22
libsrc/plus4/fast.s Normal file
View File

@@ -0,0 +1,22 @@
;
; Marco van den Heuvel, 2018-03-20
;
; void fast (void);
; /* Switch the CPU into double clock mode. */
;
.export _fast
.include "plus4.inc"
.proc _fast
lda TED_CLK
and #%11111101
sta TED_CLK
rts
.endproc

22
libsrc/plus4/isfast.s Normal file
View File

@@ -0,0 +1,22 @@
;
; Marco van den Heuvel, 2018-03-20
;
; unsigned char isfast (void);
; /* Returns 1 if the CPU is in double clock mode. */
;
.export _isfast
.include "plus4.inc"
.proc _isfast
lda TED_CLK
lsr
and #$01
ldx #$00
rts
.endproc

View File

@@ -1,17 +1,15 @@
;
; Standard joystick driver for the Plus/4. May be used multiple times when linked
; to the statically application.
; Standard joystick driver for the Plus/4 and C16.
; May be used multiple times when linked statically to an application.
;
; Ullrich von Bassewitz, 2002-12-21
; 2002-12-21, Ullrich von Bassewitz
; 2016-06-18, Greg King
;
.include "zeropage.inc"
.include "joy-kernel.inc"
.include "joy-error.inc"
.include "plus4.inc"
.macpack generic
.macpack module
@@ -26,31 +24,19 @@
; Driver signature
.byte $6A, $6F, $79 ; "joy"
.byte $6A, $6F, $79 ; ASCII "joy"
.byte JOY_API_VERSION ; Driver API version number
; Library reference
.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
@@ -98,16 +84,20 @@ COUNT:
; READ: Read a particular joystick passed in A.
;
READ: ldy #$FA ; Load index for joystick #1
READ: ldy #%11111011 ; Load index for joystick #1
tax ; Test joystick number
beq @L1
ldy #$FB ; Load index for joystick #2
ldy #%11111101 ; Load index for joystick #2
ldx #>$0000 ; (Return unsigned int)
@L1: sei
sty TED_KBD
lda TED_KBD
sty TED_KBD ; Read a joystick ...
lda TED_KBD ; ... and some keys -- it's unavoidable
cli
ldx #$00 ; Clear high byte
and #$1F
eor #$1F
rts
eor #%11111111
; The push buttons are in bits 6 and 7. Both of them cannot be %1 together.
; Therefore, bit 6 can be merged with bit 7.
clc
adc #%01000000
rts

View File

@@ -1,10 +1,11 @@
;
; Ullrich von Bassewitz, 22.11.2002
;
; BASIN replacement function
; BASIN/CHRIN replacement function
;
.export BASIN
.export CHRIN
.include "plus4.inc"
@@ -17,4 +18,4 @@
rts ; Return to caller
.endproc
CHRIN := BASIN

14
libsrc/plus4/kbrepeat.s Normal file
View File

@@ -0,0 +1,14 @@
;
; unsigned char __fastcall__ kbrepeat (unsigned char mode);
;
.export _kbrepeat
.include "plus4.inc"
_kbrepeat:
ldx KBDREPEAT ; get old value
sta KBDREPEAT ; store new value
txa ; return old value
ldx #0
rts

View File

@@ -1,10 +1,11 @@
;
; Ullrich von Bassewitz, 22.11.2002
;
; BSOUT replacement function
; BSOUT/CHROUT replacement function
;
.export BSOUT
.export CHROUT
.include "plus4.inc"
@@ -17,4 +18,4 @@
rts ; Return to caller
.endproc
CHROUT := BSOUT

View File

@@ -6,16 +6,17 @@
.export PLOT
.scope KERNAL
.include "cbm_kernal.inc"
.endscope
.include "plus4.inc"
.segment "LOWCODE" ; Must go into low memory
.proc PLOT
sta ENABLE_ROM ; Enable the ROM
jsr $FFF0 ; Call the ROM routine
jsr KERNAL::PLOT ; Call the ROM routine
sta ENABLE_RAM ; Switch back to RAM
rts ; Return to caller
.endproc

19
libsrc/plus4/kscnkey.s Normal file
View File

@@ -0,0 +1,19 @@
;
; 2002-11-22, Ullrich von Bassewitz
; 2016-08-07, Greg King
;
; SCNKEY replacement function
;
.export SCNKEY
.include "plus4.inc"
.segment "LOWCODE" ; Must go into low memory
.proc SCNKEY
sta ENABLE_ROM ; Enable the ROM
jsr $FF9F ; Call the ROM routine
sta ENABLE_RAM ; Switch back to RAM
rts ; Return to caller
.endproc

19
libsrc/plus4/kudtim.s Normal file
View File

@@ -0,0 +1,19 @@
;
; 2002-11-22, Ullrich von Bassewitz
; 2016-08-07, Greg King
;
; UDTIM replacement function
;
.export UDTIM
.include "plus4.inc"
.segment "LOWCODE" ; Must go into low memory
.proc UDTIM
sta ENABLE_ROM ; Enable the ROM
jsr $FFEA ; Call the ROM routine
sta ENABLE_RAM ; Switch back to RAM
rts ; Return to caller
.endproc

View File

@@ -32,10 +32,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:
@@ -125,7 +125,7 @@ done: lda #<argv
stx __argv + 1
rts
.segment "INITBSS"
.segment "INIT"
term: .res 1
name: .res NAME_LEN + 1

View File

@@ -11,7 +11,7 @@
.include "plus4.inc"
__randomize:
__randomize:
ldx TED_VLINELO ; Use TED rasterline as high byte
lda TIME+2 ; Use 60HZ clock as low byte
jmp _srand ; Initialize generator

View File

@@ -1,14 +1,14 @@
;
; Serial driver for the builtin 6551 ACIA of the Plus/4.
; Serial driver for the built-in 6551 ACIA of the Plus/4.
;
; Ullrich von Bassewitz, 2003-12-13
;
; The driver is based on the cc65 rs232 module, which in turn is based on
; Craig Bruce device driver for the Switftlink/Turbo-232.
; Craig Bruce's device driver for the Switftlink/Turbo-232.
;
; SwiftLink/Turbo-232 v0.90 device driver, by Craig Bruce, 14-Apr-1998.
;
; This software is Public Domain. It is in Buddy assembler format.
; This (C. Bruce) software is Public Domain. It is in Buddy assembler format.
;
; This device driver uses the SwiftLink RS-232 Serial Cartridge, available from
; Creative Micro Designs, Inc, and also supports the extensions of the Turbo232
@@ -17,7 +17,7 @@
;
; The code assumes that the kernal + I/O are in context. On the C128, call
; it from Bank 15. On the C64, don't flip out the Kernal unless a suitable
; NMI catcher is put into the RAM under then Kernal. For the SuperCPU, the
; NMI catcher is put into the RAM under the Kernal. For the SuperCPU, the
; interrupt handling assumes that the 65816 is in 6502-emulation mode.
;
@@ -36,7 +36,7 @@
; Driver signature
.byte $73, $65, $72 ; "ser"
.byte $73, $65, $72 ; ASCII "ser"
.byte SER_API_VERSION ; Serial API version number
; Library reference
@@ -45,24 +45,24 @@
; 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
;----------------------------------------------------------------------------
; I/O definitions
ACIA = $DE00
ACIA_DATA = ACIA+0 ; Data register
ACIA_STATUS = ACIA+1 ; Status register
ACIA_CMD = ACIA+2 ; Command register
ACIA_CTRL = ACIA+3 ; Control register
ACIA := $FD00
ACIA_DATA := ACIA+0 ; Data register
ACIA_STATUS := ACIA+1 ; Status register
ACIA_CMD := ACIA+2 ; Command register
ACIA_CTRL := ACIA+3 ; Control register
;----------------------------------------------------------------------------
;
@@ -130,25 +130,25 @@ 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
@@ -165,7 +165,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
@@ -244,12 +244,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
@@ -288,11 +289,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
@@ -322,34 +323,37 @@ 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 ACIA_STATUS
SER_STATUS:
lda ACIA_STATUS
ldx #0
sta (ptr1,x)
txa ; SER_ERR_OK
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 ; Run into IRQ instead
;----------------------------------------------------------------------------
; 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 ACIA_STATUS ; Check ACIA status for receive interrupt
SER_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
@@ -405,5 +409,3 @@ IRQ: lda ACIA_STATUS ; Check ACIA status for receive interrupt
jmp @L0
.endproc

22
libsrc/plus4/slow.s Normal file
View File

@@ -0,0 +1,22 @@
;
; Marco van den Heuvel, 2018-03-28
;
; void slow (void);
; /* Switch the CPU into single clock mode. */
;
.export _slow
.include "plus4.inc"
.proc _slow
lda TED_CLK
ora #%00000010
sta TED_CLK
rts
.endproc

View File

@@ -1,28 +0,0 @@
;
; Ullrich von Bassewitz, 12.11.2002
;
; 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
; */
;
.export __systime
.importzp sreg
.code
.proc __systime
lda #$FF
tax
sta sreg
sta sreg+1
rts ; Return -1
.endproc

17
libsrc/plus4/waitvsync.s Normal file
View File

@@ -0,0 +1,17 @@
;
; Written by Groepaz <groepaz@gmx.net>
;
; void waitvsync (void);
;
.export _waitvsync
.include "plus4.inc"
_waitvsync:
@l1:
lda TED_VLINEHI
and #$01
ora TED_VLINELO
bne @l1
rts