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, 26.11.1998
;
; void set_brk (unsigned Addr);
; void __fastcall__ set_brk (unsigned Addr);
; void reset_brk (void);
;

59
libsrc/pet/cbm_load.c Normal file
View File

@@ -0,0 +1,59 @@
/*
** 2020-10-15, Greg King
**
** unsigned int __fastcall__ cbm_load (const char* name,
** unsigned char device,
** void* data);
*/
#include <cbm.h>
#include <limits.h>
/* Loads file "name" from the given device to the given address, or to the load
** address of the file if "data" is the null pointer (like load"name",8,1
** in BASIC).
** Returns the number of bytes that were loaded if loading was successful;
** otherwise 0; "_oserror" contains an error-code, then.
*/
unsigned int __fastcall__ cbm_load (const char* name, unsigned char device, void* data)
{
void* load;
int length;
unsigned int size = 0;
if (cbm_open (1, device, CBM_READ, name) != 0) {
/* Can't load from a file that can't be openned. */
return 0;
}
/* Get the file's load address. */
if (cbm_read (1, &load, sizeof load) != sizeof load) {
/* Either the file wasn't found, or it was too short. (Note:
** the computer openned a file even if the drive couldn't open one.)
*/
cbm_close (1);
return 0;
}
/* If "data" doesn't hold an address, then use the file's address. */
if (data == (void*)0x0000) {
data = load;
}
/* Pull the file into RAM. [Note that, if cbm_read() grabbed more
** than 32767 bytes at a time, then its result would look negative,
** which would cancel the load.]
*/
do {
size += (length = cbm_read (1, data, INT_MAX));
data = (unsigned char*)data + length;
} while (length == INT_MAX && cbm_k_readst() == 0);
cbm_close (1);
/* "length" is -1 if there was an error. */
if (length < 0) {
size = 0;
}
return size;
}

8
libsrc/pet/cpeekcolor.s Normal file
View File

@@ -0,0 +1,8 @@
;
; 2017-06-03, Greg King
;
; unsigned char cpeekcolor (void);
;
.import return1
.export _cpeekcolor := return1 ; always COLOR_WHITE

View File

@@ -7,14 +7,13 @@
.export _cputcxy, _cputc, cputdirect, putchar
.export newline, plot
.import popa, _gotoxy
.import gotoxy
.include "pet.inc"
_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

View File

@@ -12,7 +12,6 @@
.include "zeropage.inc"
.include "pet.inc"
.include "../cbm/cbm.inc"
; ------------------------------------------------------------------------
; Startup code
@@ -94,7 +93,7 @@ L2: lda zpsave,x
; ------------------------------------------------------------------------
.segment "INITBSS"
.segment "INIT"
zpsave: .res zpspace

View File

@@ -9,7 +9,7 @@
; ------------------------------------------------------------------------
.segment "INIT"
.segment "ONCE"
initirq:
lda IRQVec

View File

@@ -10,6 +10,7 @@
.include "joy-kernel.inc"
.include "joy-error.inc"
.include "pet.inc"
.macpack module
@@ -28,34 +29,18 @@
.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
JOY_COUNT = 2 ; Number of joysticks we support
VIA_PRA := $E841 ; Port register A
VIA_DDRA := $E843 ; Data direction register A
.code
; ------------------------------------------------------------------------
@@ -101,9 +86,9 @@ READ: lda #%10000000 ; via port A Data-Direction
; Read joystick 1
joy1: lda #$80 ; via port A read/write
sta VIA_PRA ; (output one at PA7)
sta VIA_PA1 ; (output one at PA7)
lda VIA_PRA ; via port A read/write
lda VIA_PA1 ; via port A read/write
and #$1f ; get bit 4-0 (PA4-PA0)
eor #$1f
rts
@@ -111,13 +96,13 @@ joy1: lda #$80 ; via port A read/write
; Read joystick 2
joy2: lda #$00 ; via port A read/write
sta VIA_PRA ; (output zero at PA7)
sta VIA_PA1 ; (output zero at PA7)
lda VIA_PRA ; via port A read/write
lda VIA_PA1 ; via port A read/write
and #$0f ; get bit 3-0 (PA3-PA0)
sta tmp1 ; joy 4 directions
lda VIA_PRA ; via port A read/write
lda VIA_PA1 ; via port A read/write
and #%00100000 ; get bit 5 (PA5)
lsr
ora tmp1

View File

@@ -27,24 +27,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
@@ -97,7 +85,7 @@ READ:
joy1:
lda #0
sta VIA_DDRA
lda VIA_PRA
lda VIA_PA1
and #$0f
cmp #$0c
bne @notc1
@@ -114,7 +102,7 @@ joy1:
joy2:
lda #0
sta VIA_DDRA
lda VIA_PRA
lda VIA_PA1
lsr
lsr
lsr

29
libsrc/pet/kbrepeat.s Normal file
View File

@@ -0,0 +1,29 @@
;
; unsigned char __fastcall__ kbrepeat (unsigned char mode);
;
; 2017-06-16, Groepaz
; 2017-09-05, Greg King
;
.export _kbrepeat
.include "pet.inc"
_kbrepeat:
ldx #>$0000
ldy SCR_LINELEN
cpy #40 + 1
bcc L1 ; branch if screen is 40 columns wide
ldy KBDREPEAT80 ; get old value
sta KBDREPEAT80 ; store new value
tya ; return old value
rts
L1: tay
lda KBDREPEAT40B ; get REPEAT-key flag (used by some editor ROMs)
lsr a ; move bit 0 into bit 7
ror a
ora KBDREPEAT40 ; combine with old key-REPEAT flags
sty KBDREPEAT40
rts

View File

@@ -1,19 +1,20 @@
;
; Ullrich von Bassewitz, 19.11.2002
;
; BSOUT replacement function for the PETs
; BSOUT/CHROUT replacement function for the PETs
;
.export BSOUT
.export CHROUT
.import checkst
.proc BSOUT
jsr $FFD2 ; Call kernal function
jsr $FFD2 ; Call Kernal function
jmp checkst ; Check status, return carry on error
.endproc
CHROUT := BSOUT

View File

@@ -15,5 +15,3 @@
.endproc

View File

@@ -10,7 +10,7 @@
.proc CLOSE
ldx PET_DETECT
cpx #PET_4000
bne @L1
@@ -19,4 +19,3 @@
.endproc

View File

@@ -4,25 +4,12 @@
; PET kernal functions
;
.include "cbm_kernal.inc"
.export CLRCH
.export BASIN
.export CHRIN
.export STOP
.export GETIN
.export CLALL
.export UDTIM
;-----------------------------------------------------------------------------
; Functions that are available in the kernal jump table
CLRCH = $FFCC
BASIN = $FFCF
STOP = $FFE1
GETIN = $FFE4
CLALL = $FFE7
UDTIM = $FFEA

View File

@@ -5,7 +5,7 @@
;
.export RDTIM
.include "pet.inc"
@@ -20,4 +20,3 @@
.endproc

View File

@@ -15,7 +15,6 @@
stx DEVNUM ; Device address
sty SECADR ; Secondary address
rts
.endproc

View File

@@ -10,7 +10,7 @@
.proc SETNAM
sta FNLEN
stx FNADR
sty FNADR+1
@@ -18,4 +18,3 @@
.endproc

View File

@@ -16,10 +16,10 @@ 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"
.proc initmainargs
@@ -111,7 +111,7 @@ done: lda #<argv
.endproc
.segment "INITBSS"
.segment "INIT"
term: .res 1
name: .res NAME_LEN + 1

View File

@@ -11,7 +11,7 @@
.include "pet.inc"
__randomize:
__randomize:
ldx TIME+2
lda TIME+1 ; Use 60HZ clock
jmp _srand ; Initialize generator

16
libsrc/pet/waitvsync.s Normal file
View File

@@ -0,0 +1,16 @@
;
; Written by Robin Harbron, requires 12" monitor
;
; void waitvsync (void);
;
.export _waitvsync
.include "pet.inc"
_waitvsync:
@l1:
lda VIA_PB
and #%00100000
bne @l1
rts