This commit is contained in:
polluks
2021-12-30 00:42:29 +01:00
57 changed files with 2002 additions and 88 deletions

View File

@@ -34,6 +34,7 @@ TARGETS = apple2 \
sim6502 \
sim65c02 \
supervision \
sym1 \
telestrat
DRVTYPES = emd \

View File

@@ -93,9 +93,7 @@ joy1: lda #$7F
sta CIA1_PRA
lda CIA1_PRB
cli
and #$1F
eor #$1F
rts
jmp end
; Read joystick 2
@@ -107,8 +105,6 @@ joy2: ldx #0
lda CIA1_PRA
sty CIA1_DDRA
cli
and #$1F
end: and #$1F
eor #$1F
rts

View File

@@ -75,7 +75,7 @@ int __fastcall__ posix_memalign (void** memptr, size_t alignment, size_t size)
}
/* Test alignment: is it a power of two? There must be only one bit set. */
if (alignment == 0 || (alignment & --alignment) != 0) {
if (alignment == 0 || (alignment & (alignment - 1)) != 0) {
*memptr = NULL;
return EINVAL;
}
@@ -86,7 +86,7 @@ int __fastcall__ posix_memalign (void** memptr, size_t alignment, size_t size)
** overhead added one time; and, the worst thing that might happen is that
** we cannot free the upper and lower blocks.
*/
b = malloc (size + alignment);
b = malloc (--alignment + size);
/* Handle out-of-memory */
if (b == NULL) {
@@ -169,6 +169,3 @@ int __fastcall__ posix_memalign (void** memptr, size_t alignment, size_t size)
return EOK;
}

18
libsrc/sym1/beep.s Normal file
View File

@@ -0,0 +1,18 @@
;
; Wayne Parham (wayne@parhamdata.com)
;
; void beep (void);
;
.include "sym1.inc"
.export _beep
.segment "CODE"
.proc _beep: near
jsr BEEP ; Beep
rts
.endproc

57
libsrc/sym1/crt0.s Normal file
View File

@@ -0,0 +1,57 @@
;
; Startup code for cc65 (Sym-1 version)
;
.export _init, _exit
.export __STARTUP__ : absolute = 1 ; Mark as startup
.import _main
.import initlib, donelib, copydata, zerobss
.import __RAM_START__, __RAM_SIZE__ ; Linker generated
.import __STACKSIZE__ ; Linker generated
.include "zeropage.inc"
.include "sym1.inc"
; Place the startup code in a special segment
.segment "STARTUP"
; A little light housekeeping
_init: jsr ACCESS ; Unlock System RAM
cld ; Clear decimal mode
; Turn off console echo
lda TECHO
and #$7F
sta TECHO
; Set cc65 argument stack pointer
lda #<(__RAM_START__ + __RAM_SIZE__)
sta sp
lda #>(__RAM_START__ + __RAM_SIZE__)
sta sp+1
; Initialize memory storage
jsr zerobss ; Clear BSS segment
jsr copydata ; Initialize DATA segment
jsr initlib ; Run constructors
; Call main()
jsr _main
; Back from main (this is also the _exit entry)
_exit: jsr donelib ; Run destructors
lda TECHO
ora #$80 ; Re-enable console echo
sta TECHO
jsr NACCES ; Lock System RAM
rts ; Re-enter Sym-1 monitor

5
libsrc/sym1/ctype.s Normal file
View File

@@ -0,0 +1,5 @@
; Character specification table.
;
; uses the "common" definition
.include "ctype_common.inc"

18
libsrc/sym1/display.s Normal file
View File

@@ -0,0 +1,18 @@
;
; Wayne Parham (wayne@parhamdata.com)
;
; void fdisp (void);
;
.include "sym1.inc"
.export _fdisp
.segment "CODE"
.proc _fdisp: near
jsr SCAND ; Flash Display
rts
.endproc

53
libsrc/sym1/read.s Normal file
View File

@@ -0,0 +1,53 @@
;
; Wayne Parham (wayne@parhamdata.com)
;
; int __fastcall__ read (int fd, void* buf, unsigned count);
;
.include "sym1.inc"
.import popax, popptr1
.importzp ptr1, ptr2, ptr3
.export _read
.proc _read
sta ptr3
stx ptr3+1 ; Count in ptr3
inx
stx ptr2+1 ; Increment and store in ptr2
tax
inx
stx ptr2
jsr popptr1 ; Buffer address in ptr1
jsr popax
begin: dec ptr2
bne getch
dec ptr2+1
beq done ; If buffer full, return
getch: jsr INTCHR ; Get character using Monitor ROM call
jsr OUTCHR ; Echo it
and #$7F ; Clear top bit
cmp #$07 ; Check for '\a'
bne chkcr ; ...if BEL character
jsr BEEP ; Make beep sound
chkcr: cmp #$0D ; Check for '\r'
bne putch ; ...if CR character
lda #$0A ; Replace with '\n'
jsr OUTCHR ; and echo it
putch: ldy #$00 ; Put char into return buffer
sta (ptr1),y
inc ptr1 ; Increment pointer
bne begin
inc ptr1+1
bne begin
done: lda ptr3
ldx ptr3+1
rts ; Return count
.endproc

46
libsrc/sym1/tapeio.s Normal file
View File

@@ -0,0 +1,46 @@
;
; Wayne Parham (wayne@parhamdata.com)
;
; int __fastcall__ loadt (unsigned char id);
; int __fastcall__ dumpt (unsigned char id, void* start_addr, void* end_addr);
;
.include "sym1.inc"
.import popa, popax, return0, return1
.export _loadt, _dumpt
.segment "CODE"
.proc _loadt: near
sta P1L ; Tape record ID to P1L
ldx #$00
stx P1H
ldy #$80
jsr LOADT ; Read data from tape
bcs error
jmp return0 ; Return 0 if sucessful
error: jmp return1 ; or 1 if not
.endproc
.proc _dumpt: near
sta P3L ; End address
stx P3H
jsr popax
sta P2L ; Start address
stx P2H
jsr popa
sta P1L ; Tape Record ID
ldx #$00
stx P1H
ldy #$80
jsr DUMPT ; Write data to tape
bcs error
jmp return0 ; Return 0 if sucessful
error: jmp return1 ; or 1 if not
.endproc

51
libsrc/sym1/write.s Normal file
View File

@@ -0,0 +1,51 @@
;
; Wayne Parham (wayne@parhamdata.com)
;
; int __fastcall__ write (int fd, const void* buf, int count);
;
.include "sym1.inc"
.import popax, popptr1
.importzp ptr1, ptr2, ptr3
.export _write
.proc _write
sta ptr3
stx ptr3+1 ; Count in ptr3
inx
stx ptr2+1 ; Increment and store in ptr2
tax
inx
stx ptr2
jsr popptr1 ; Buffer address in ptr1
jsr popax
begin: dec ptr2
bne outch
dec ptr2+1
beq done
outch: ldy #0
lda (ptr1),y
jsr OUTCHR ; Send character using Monitor call
cmp #$07 ; Check for '\a'
bne chklf ; ...if BEL character
jsr BEEP ; Make beep sound
chklf: cmp #$0A ; Check for 'n'
bne next ; ...if LF character
lda #$0D ; Add a carriage return
jsr OUTCHR
next: inc ptr1
bne begin
inc ptr1+1
jmp begin
done: lda ptr3
ldx ptr3+1
rts ; Return count
.endproc