From 071c58bda25a3c02296c35652feddda27800ff35 Mon Sep 17 00:00:00 2001 From: cuz Date: Sat, 26 Mar 2005 17:03:30 +0000 Subject: [PATCH] New version from Oliver Schmidt git-svn-id: svn://svn.cc65.org/cc65/trunk@3421 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- libsrc/apple2/Makefile | 9 +-- libsrc/apple2/_scrsize.s | 11 ++- libsrc/apple2/apple2.inc | 54 +++++++------ libsrc/apple2/cclear.s | 20 ++--- libsrc/apple2/cgetc.s | 42 +++++----- libsrc/apple2/chline.s | 44 ++++++----- libsrc/apple2/clrscr.s | 13 ++-- libsrc/apple2/cputc.s | 137 +++++++++++++++++++-------------- libsrc/apple2/cvline.s | 43 ++++++----- libsrc/apple2/dosdetect.s | 61 +++++++-------- libsrc/apple2/get_ostype.s | 113 +++++++++++++-------------- libsrc/apple2/getenv.s | 8 +- libsrc/apple2/joy_stddrv.s | 9 ++- libsrc/apple2/kbhit.s | 29 ++++--- libsrc/apple2/revers.s | 18 ++--- libsrc/apple2/rvtabz.s | 9 +++ libsrc/apple2/systime.s | 4 +- libsrc/apple2/textframe.s | 105 +++++++++++++++++++++++++ libsrc/apple2/tgi_mode_table.s | 18 +++-- libsrc/apple2/wherex.s | 17 ++-- libsrc/apple2/wherey.s | 19 +++-- libsrc/apple2enh/Makefile | 49 +++++++++--- libsrc/apple2enh/_scrsize.s | 14 ---- libsrc/apple2enh/chline.s | 39 ---------- libsrc/apple2enh/cputc.s | 89 --------------------- libsrc/apple2enh/cvline.s | 30 -------- libsrc/apple2enh/textframe.s | 106 ------------------------- 27 files changed, 512 insertions(+), 598 deletions(-) create mode 100644 libsrc/apple2/rvtabz.s create mode 100644 libsrc/apple2/textframe.s delete mode 100644 libsrc/apple2enh/_scrsize.s delete mode 100644 libsrc/apple2enh/chline.s delete mode 100644 libsrc/apple2enh/cputc.s delete mode 100644 libsrc/apple2enh/cvline.s delete mode 100644 libsrc/apple2enh/textframe.s diff --git a/libsrc/apple2/Makefile b/libsrc/apple2/Makefile index aade3112f..1444ef1d4 100644 --- a/libsrc/apple2/Makefile +++ b/libsrc/apple2/Makefile @@ -57,21 +57,20 @@ OBJS= _scrsize.o \ mainargs.o \ oserrlist.o \ randomize.o \ - rbascalc.o \ rcout.o \ - read.o \ + read.o \ revers.o \ rhome.o \ rom.o \ rpread.o \ rrdkey.o \ - rsetwnd.o \ + rvtabz.o \ systime.o \ sysuname.o \ tgi_mode_table.o\ wherex.o \ - wherey.o \ - write.o + wherey.o \ + write.o #-------------------------------------------------------------------------- # Drivers diff --git a/libsrc/apple2/_scrsize.s b/libsrc/apple2/_scrsize.s index 29d54edaf..62988ae16 100644 --- a/libsrc/apple2/_scrsize.s +++ b/libsrc/apple2/_scrsize.s @@ -4,9 +4,14 @@ ; Screen size variables ; - .export screensize + .export screensize + + .include "apple2.inc" screensize: - ldx #40 - ldy #24 + ldx WNDWDTH + lda WNDBTM + sec + sbc WNDTOP + tay rts diff --git a/libsrc/apple2/apple2.inc b/libsrc/apple2/apple2.inc index 45b36efee..e594be9e5 100644 --- a/libsrc/apple2/apple2.inc +++ b/libsrc/apple2/apple2.inc @@ -2,43 +2,47 @@ ;----------------------------------------------------------------------------- ; Zero page stuff -WNDWDTH := $21 ; Right edge of text window -CH := $24 ; Cursor horizontal position -CV := $25 ; Cursor vertical position -BASL := $28 ; Text base address -INVFLG := $32 ; Normal/inverse(/flash) -RNDL := $4E ; Random counter low -RNDH := $4F ; Random counter high -HIMEM := $73 ; Highest available memory address+1 +WNDLFT := $20 ; Text window left +WNDWDTH := $21 ; Text window width +WNDTOP := $22 ; Text window top +WNDBTM := $23 ; Text window bottom+1 +CH := $24 ; Cursor horizontal position +CV := $25 ; Cursor vertical position +BASL := $28 ; Text base address low +BASH := $29 ; Text base address high +INVFLG := $32 ; Normal/inverse(/flash) +PROMPT := $33 ; Used by GETLN +RNDL := $4E ; Random counter low +RNDH := $4F ; Random counter high +HIMEM := $73 ; Highest available memory address+1 ;----------------------------------------------------------------------------- ; Vectors -SOFTEV := $03F2 ; Vector for warm start -PWREDUP := $03F4 ; This must be = EOR #$A5 of SOFTEV+1 -DOSWARM := $03D0 ; DOS warmstart vector -BRKVec := $03F0 ; Break vector -MLI := $BF00 ; ProDOS Machine Language Interface +DOSWARM := $03D0 ; DOS warmstart vector +BRKVec := $03F0 ; Break vector +SOFTEV := $03F2 ; Vector for warm start +PWREDUP := $03F4 ; This must be = EOR #$A5 of SOFTEV+1 ;----------------------------------------------------------------------------- ; Hardware ; Keyboard input -KBD := $C000 ; Read keyboard -KBDSTRB := $C010 ; Clear keyboard strobe +KBD := $C000 ; Read keyboard +KBDSTRB := $C010 ; Clear keyboard strobe ; 80 column card switches -CLRALTCHAR := $C00E ; Normal Apple II char set -SETALTCHAR := $C00F ; Norm/inv LC, no flash -ALTCHARSET := $C01E ; >127 if alt charset switched in -RD80VID := $C01F ; >127 if 80 column video enabled +CLRALTCHAR := $C00E ; Normal Apple II char set +SETALTCHAR := $C00F ; Norm/inv LC, no flash +ALTCHARSET := $C01E ; >127 if alt charset switched in +RD80VID := $C01F ; >127 if 80 column video enabled ; Video soft switches -MIXCLR := $C052 ; Disable 4 lines of text -MIXSET := $C053 ; Enable 4 lines of text -LOWSCR := $C054 ; Page 1 -HISCR := $C055 ; Page 2 +MIXCLR := $C052 ; Disable 4 lines of text +MIXSET := $C053 ; Enable 4 lines of text +LOWSCR := $C054 ; Page 1 +HISCR := $C055 ; Page 2 ; Game controller -BUTN0 := $C061 ; Open-Apple Key -BUTN1 := $C062 ; Closed-Apple Key +BUTN0 := $C061 ; Open-Apple Key +BUTN1 := $C062 ; Closed-Apple Key diff --git a/libsrc/apple2/cclear.s b/libsrc/apple2/cclear.s index de6f01ef4..ca973686b 100644 --- a/libsrc/apple2/cclear.s +++ b/libsrc/apple2/cclear.s @@ -1,19 +1,19 @@ ; ; Ullrich von Bassewitz, 08.08.1998 ; -; void cclearxy (unsigned char x, unsigned char y, unsigned char length); -; void cclear (unsigned char length); +; void __fastcall__ cclearxy (unsigned char x, unsigned char y, unsigned char length); +; void __fastcall__ cclear (unsigned char length); ; - .export _cclearxy, _cclear - .import popa, _gotoxy, chlinedirect + .export _cclearxy, _cclear + .import popa, _gotoxy, chlinedirect _cclearxy: - pha ; Save the length - jsr popa ; Get y - jsr _gotoxy ; Call this one, will pop params - pla ; Restore the length and run into _cclear + pha ; Save the length + jsr popa ; Get y + jsr _gotoxy ; Call this one, will pop params + pla ; Restore the length and run into _cclear _cclear: - ldx #' ' | $80 ; Blank, screen code - jmp chlinedirect + ldx #' ' | $80 ; Blank, screen code + jmp chlinedirect diff --git a/libsrc/apple2/cgetc.s b/libsrc/apple2/cgetc.s index c1be4dc44..d0695cdb5 100644 --- a/libsrc/apple2/cgetc.s +++ b/libsrc/apple2/cgetc.s @@ -1,25 +1,23 @@ - ;; - ;; Kevin Ruland - ;; - ;; char cgetc (void); - ;; - ;; If open_apple key is pressed then the high-bit of the - ;; key is set. - - .export _cgetc +; +; Kevin Ruland +; +; char cgetc (void); +; +; If open_apple key is pressed then the high-bit of the key is set. +; - .include "apple2.inc" + .export _cgetc + + .include "apple2.inc" _cgetc: - lda KBD - bpl _cgetc ; if < 128, no key pressed - ;; At this time, the high bit of the key pressed - ;; is set - bit KBDSTRB ; clear keyboard strobe - bit BUTN0 ; check if OpenApple is down - bmi pressed - and #$7F ; If not down, then clear high bit -pressed: - ldx #$00 - rts - \ No newline at end of file + lda KBD + bpl _cgetc ; if < 128, no key pressed + + ; At this time, the high bit of the key pressed is set + bit KBDSTRB ; clear keyboard strobe + bit BUTN0 ; check if OpenApple is down + bmi :+ + and #$7F ; If not down, then clear high bit +: ldx #$00 + rts diff --git a/libsrc/apple2/chline.s b/libsrc/apple2/chline.s index ab07991b0..a9a0c2586 100644 --- a/libsrc/apple2/chline.s +++ b/libsrc/apple2/chline.s @@ -1,29 +1,37 @@ ; ; Ullrich von Bassewitz, 08.08.1998 ; -; void chlinexy (unsigned char x, unsigned char y, unsigned char length); -; void chline (unsigned char length); +; void __fastcall__ chlinexy (unsigned char x, unsigned char y, unsigned char length); +; void __fastcall__ chline (unsigned char length); ; - .export _chlinexy, _chline, chlinedirect - .import popa, _gotoxy, cputdirect - .importzp tmp1 + .export _chlinexy, _chline, chlinedirect + .import popa, _gotoxy, cputdirect + + .include "zeropage.inc" + .include "apple2.inc" _chlinexy: - pha ; Save the length - jsr popa ; Get y - jsr _gotoxy ; Call this one, will pop params - pla ; Restore the length and run into _chline + pha ; Save the length + jsr popa ; Get y + jsr _gotoxy ; Call this one, will pop params + pla ; Restore the length and run into _chline _chline: - ldx #'-' | $80 ; Horizontal line, screen code + .ifdef __APPLE2ENH__ + ldx #'S' ; MouseText character + ldy INVFLG + cpy #$FF ; Normal character display mode? + beq chlinedirect + .endif + ldx #'-' | $80 ; Horizontal line, screen code chlinedirect: - cmp #$00 ; Is the length zero? - beq done ; Jump if done - sta tmp1 -: txa ; Screen code - jsr cputdirect ; Direct output - dec tmp1 - bne :- -done: rts + cmp #$00 ; Is the length zero? + beq done ; Jump if done + sta tmp1 +: txa ; Screen code + jsr cputdirect ; Direct output + dec tmp1 + bne :- +done: rts diff --git a/libsrc/apple2/clrscr.s b/libsrc/apple2/clrscr.s index b31f4cf76..aee23e5dd 100644 --- a/libsrc/apple2/clrscr.s +++ b/libsrc/apple2/clrscr.s @@ -1,9 +1,10 @@ - ;; - ;; Kevin Ruland - ;; - ;; void clrscr (void); +; +; Kevin Ruland +; +; void clrscr (void); +; - .export _clrscr - .import HOME + .export _clrscr + .import HOME _clrscr := HOME diff --git a/libsrc/apple2/cputc.s b/libsrc/apple2/cputc.s index a09dadd32..75cc99d9a 100644 --- a/libsrc/apple2/cputc.s +++ b/libsrc/apple2/cputc.s @@ -1,79 +1,104 @@ ; ; Ullrich von Bassewitz, 06.08.1998 ; -; void cputcxy (unsigned char x, unsigned char y, char c); -; void cputc (char c); +; void __fastcall__ cputcxy (unsigned char x, unsigned char y, char c); +; void __fastcall__ cputc (char c); ; - .constructor initconio - .export _cputcxy, _cputc - .export _gotoxy, cputdirect - .export newline, putchar + .ifdef __APPLE2ENH__ + .constructor initconio + .endif + .export _cputcxy, _cputc + .export _gotoxy, cputdirect + .export newline, putchar - .import popa, SETWND, BASCALC + .import popa, VTABZ - .include "apple2.inc" + .include "apple2.inc" -; ------------------------------------------------------------------------ -; Initialization - -.segment "INIT" + .segment "INIT" + .ifdef __APPLE2ENH__ initconio: - lda #$FF ; Normal character display mode - sta INVFLG - lda #$00 - jmp SETWND ; Reset text window to full screen + sta SETALTCHAR ; Switch in alternate charset + rts + .endif -; ------------------------------------------------------------------------ -; Plot a character - also used as internal function + .code -.code +; Plot a character - also used as internal function _cputcxy: - pha ; Save C - jsr popa ; Get Y - jsr _gotoxy - pla ; Restore C + pha ; Save C + jsr popa ; Get Y + jsr _gotoxy + pla ; Restore C _cputc: - cmp #$0D ; Test for \r = carrage return - beq left - cmp #$0A ; Test for \n = line feed - beq newline - ora #$80 ; Turn on high bit - cmp #$E0 ; Test for lowercase - bcc cputdirect - and #$DF ; Convert to uppercase + cmp #$0D ; Test for \r = carrage return + beq left + cmp #$0A ; Test for \n = line feed + beq newline + ora #$80 ; Turn on high bit + .ifndef __APPLE2ENH__ + cmp #$E0 ; Test for lowercase + bcc cputdirect + and #$DF ; Convert to uppercase + .endif cputdirect: - jsr putchar - inc CH ; Bump to next column - lda CH - cmp #40 - bne done -left: lda #$00 ; Goto left edge of screen - sta CH -done: rts + jsr putchar + inc CH ; Bump to next column + lda CH + cmp WNDWDTH + bcc :+ +left: lda #$00 ; Goto left edge of screen + sta CH +: rts newline: - inc CV - lda CV - cmp #24 - bne :+ - lda #$00 - sta CV -: jmp BASCALC - + inc CV ; Bump to next line + lda CV + cmp WNDBTM + bcc :+ + lda WNDTOP ; Goto top of screen + sta CV +: jmp VTABZ + putchar: - and INVFLG ; Apply normal, inverse, flash - ldy CH - sta (BASL),Y - rts + .ifdef __APPLE2ENH__ + ldy INVFLG + cpy #$FF ; Normal character display mode? + beq put + cmp #$E0 ; Lowercase? + bcc mask + and #$7F ; Inverse lowercase + bra put + .endif +mask: and INVFLG ; Apply normal, inverse, flash +put: ldy CH + .ifdef __APPLE2ENH__ + bit RD80VID ; In 80 column mode? + bpl col40 ; No, in 40 cols + pha + tya + lsr ; Div by 2 + tay + pla + bcs col40 ; Odd cols go in 40 col memory + bit HISCR + sta (BASL),Y + bit LOWSCR + rts + .endif +col40: sta (BASL),Y + rts _gotoxy: - sta CV ; Store Y - jsr BASCALC - jsr popa ; Get X - sta CH ; Store X - rts + clc + adc WNDTOP + sta CV ; Store Y + jsr VTABZ + jsr popa ; Get X + sta CH ; Store X + rts diff --git a/libsrc/apple2/cvline.s b/libsrc/apple2/cvline.s index 044e73d58..280e4ced3 100644 --- a/libsrc/apple2/cvline.s +++ b/libsrc/apple2/cvline.s @@ -1,30 +1,35 @@ ; ; Ullrich von Bassewitz, 08.08.1998 ; -; void cvlinexy (unsigned char x, unsigned char y, unsigned char length); -; void cvline (unsigned char length); +; void __fastcall__ cvlinexy (unsigned char x, unsigned char y, unsigned char length); +; void __fastcall__ cvline (unsigned char length); ; - .export _cvlinexy, _cvline, cvlinedirect - .import popa, _gotoxy, putchar, newline - .importzp tmp1 + .export _cvlinexy, _cvline, cvlinedirect + .import popa, _gotoxy, putchar, newline + + .include "zeropage.inc" _cvlinexy: - pha ; Save the length - jsr popa ; Get y - jsr _gotoxy ; Call this one, will pop params - pla ; Restore the length and run into _cvline + pha ; Save the length + jsr popa ; Get y + jsr _gotoxy ; Call this one, will pop params + pla ; Restore the length and run into _cvline _cvline: - ldx #'!' | $80 ; Vertical line, screen code + .ifdef __APPLE2ENH__ + ldx #'|' | $80 ; Vertical line, screen code + .else + ldx #'!' | $80 ; Vertical line, screen code + .endif cvlinedirect: - cmp #$00 ; Is the length zero? - beq done ; Jump if done - sta tmp1 -: txa ; Screen code - jsr putchar ; Write, no cursor advance - jsr newline ; Advance cursor to next line - dec tmp1 - bne :- -done: rts + cmp #$00 ; Is the length zero? + beq done ; Jump if done + sta tmp1 +: txa ; Screen code + jsr putchar ; Write, no cursor advance + jsr newline ; Advance cursor to next line + dec tmp1 + bne :- +done: rts diff --git a/libsrc/apple2/dosdetect.s b/libsrc/apple2/dosdetect.s index 248ea61a0..b8553ecbb 100644 --- a/libsrc/apple2/dosdetect.s +++ b/libsrc/apple2/dosdetect.s @@ -3,45 +3,46 @@ ; ; Identify DOS version we're running on as one of these: ; -; AppleDOS 3.3 $00 -; ProDOS 1.0.1 $10 -; ProDOS 1.0.2 $10 -; ProDOS 1.1.1 $11 -; ProDOS 1.2 $12 -; ProDOS 1.3 $13 -; ProDOS 1.4 $14 -; ProDOS 1.5 $15 -; ProDOS 1.6 $16 -; ProDOS 1.7 $17 -; ProDOS 1.8 $18 -; ProDOS 1.9 $18 -; ProDOS 2.0.1 $21 -; ProDOS 2.0.2 $22 -; ProDOS 2.0.3 $23 +; AppleDOS 3.3 - $00 +; ProDOS 8 1.0.1 - $10 +; ProDOS 8 1.0.2 - $10 +; ProDOS 8 1.1.1 - $11 +; ProDOS 8 1.2 - $12 +; ProDOS 8 1.3 - $13 +; ProDOS 8 1.4 - $14 +; ProDOS 8 1.5 - $15 +; ProDOS 8 1.6 - $16 +; ProDOS 8 1.7 - $17 +; ProDOS 8 1.8 - $18 +; ProDOS 8 1.9 - $18 +; ProDOS 8 2.0.1 - $21 +; ProDOS 8 2.0.2 - $22 +; ProDOS 8 2.0.3 - $23 +; - .constructor initdostype - .export __dos_type + .constructor initdostype + .export __dos_type - .include "apple2.inc" + .include "mli.inc" ; Identify DOS version according to: ; - "Beneath Apple ProDOS", chapter 6-63 ; - "Apple II ProDOS 8 TechNote #023: ProDOS 8 Changes and Minutia" ; - ProDOS TechRefMan, chapter 5.2.4 -.segment "INIT" + .segment "INIT" initdostype: - lda MLI - cmp #$4C ; Is MLI present? (JMP opcode) - bne done - lda $BFFF ; ProDOS KVERSION - cmp #$10 - bcs :+ - ora #$10 ; Make high nibble match major version -: sta __dos_type -done: rts + lda ENTRY + cmp #$4C ; Is MLI present? (JMP opcode) + bne done + lda KVERSION ; ProDOS 8 kernel version + cmp #$10 + bcs :+ + ora #$10 ; Make high nibble match major version +: sta __dos_type +done: rts -.bss + .bss -__dos_type: .res 1 +__dos_type: .res 1 diff --git a/libsrc/apple2/get_ostype.s b/libsrc/apple2/get_ostype.s index ba2347ab5..98cd99fb8 100644 --- a/libsrc/apple2/get_ostype.s +++ b/libsrc/apple2/get_ostype.s @@ -4,76 +4,67 @@ ; unsigned char get_ostype(void) ; - .constructor initostype - .export _get_ostype + .constructor initostype + .export _get_ostype ; Identify machine according to: ; "Apple II Miscellaneous TechNote #7: Apple II Family Identification" -; ------------------------------------------------------------------------ -; Initialization - -.segment "INIT" + .segment "INIT" initostype: - sec - jsr $FE1F - bcs nogs - tya - ora #$80 -done: sta ostype - rts -nogs: ldx #$FF -next: inx - lda value,x - ldy index,x - beq done ; $00 is no valid index - cmp $FB00,y - beq next -: inx - ldy index,x - bne :- - beq next ; Branch always - -; ------------------------------------------------------------------------ + sec + jsr $FE1F + bcs nogs + tya + ora #$80 +done: sta ostype + rts +nogs: ldx #$FF +next: inx + lda value,x + ldy index,x + beq done ; $00 is no valid index + cmp $FB00,y + beq next +: inx + ldy index,x + bne :- + beq next ; Branch always -.code - -_get_ostype: - lda ostype - ldx #$00 - rts +index: .byte $B3, $00 ; Apple ][ + .byte $B3, $1E, $00 ; Apple ][+ + .byte $B3, $1E, $00 ; Apple /// (emulation) + .byte $B3, $C0, $00 ; Apple //e + .byte $B3, $C0, $DD, $BE, $00 ; Apple //e Option Card + .byte $B3, $C0, $00 ; Apple //e (enhanced) + .byte $B3, $C0, $BF, $00 ; Apple //c + .byte $B3, $C0, $BF, $00 ; Apple //c (3.5 ROM) + .byte $B3, $C0, $BF, $00 ; Apple //c (Mem. Exp.) + .byte $B3, $C0, $BF, $00 ; Apple //c (Rev. Mem. Exp.) + .byte $B3, $C0, $BF, $00 ; Apple //c Plus + .byte $00 +value: .byte $38, $10 ; Apple ][ + .byte $EA, $AD, $11 ; Apple ][+ + .byte $EA, $8A, $20 ; Apple /// (emulation) + .byte $06, $EA, $30 ; Apple //e + .byte $06, $E0, $02, $00, $40 ; Apple //e Option Card + .byte $06, $E0, $31 ; Apple //e (enhanced) + .byte $06, $00, $FF, $50 ; Apple //c + .byte $06, $00, $00, $51 ; Apple //c (3.5 ROM) + .byte $06, $00, $03, $53 ; Apple //c (Mem. Exp.) + .byte $06, $00, $04, $54 ; Apple //c (Rev. Mem. Exp.) + .byte $06, $00, $05, $55 ; Apple //c Plus + .byte $00 -.rodata - -index: .byte $B3, $00 ; Apple ][ - .byte $B3, $1E, $00 ; Apple ][+ - .byte $B3, $1E, $00 ; Apple /// (emulation) - .byte $B3, $C0, $00 ; Apple //e - .byte $B3, $C0, $DD, $BE, $00 ; Apple //e Option Card - .byte $B3, $C0, $00 ; Apple //e (enhanced) - .byte $B3, $C0, $BF, $00 ; Apple //c - .byte $B3, $C0, $BF, $00 ; Apple //c (3.5 ROM) - .byte $B3, $C0, $BF, $00 ; Apple //c (Mem. Exp.) - .byte $B3, $C0, $BF, $00 ; Apple //c (Rev. Mem. Exp.) - .byte $B3, $C0, $BF, $00 ; Apple //c Plus - .byte $00 - -value: .byte $38, $10 ; Apple ][ - .byte $EA, $AD, $11 ; Apple ][+ - .byte $EA, $8A, $20 ; Apple /// (emulation) - .byte $06, $EA, $30 ; Apple //e - .byte $06, $E0, $02, $00, $40 ; Apple //e Option Card - .byte $06, $E0, $31 ; Apple //e (enhanced) - .byte $06, $00, $FF, $50 ; Apple //c - .byte $06, $00, $00, $51 ; Apple //c (3.5 ROM) - .byte $06, $00, $03, $53 ; Apple //c (Mem. Exp.) - .byte $06, $00, $04, $54 ; Apple //c (Rev. Mem. Exp.) - .byte $06, $00, $05, $55 ; Apple //c Plus - .byte $00 + .code +_get_ostype: + lda ostype + ldx #$00 + rts -.bss + .bss -ostype: .res 1 +ostype: .res 1 diff --git a/libsrc/apple2/getenv.s b/libsrc/apple2/getenv.s index c69ec35bc..4f928cd52 100644 --- a/libsrc/apple2/getenv.s +++ b/libsrc/apple2/getenv.s @@ -1,12 +1,12 @@ ; ; Ullrich von Bassewitz, 2003-05-02 ; -; char* getenv (const char* name); +; char* __fastcall__ getenv (const char* name); ; - .export _getenv - .import return0 + .export _getenv + .import return0 -_getenv = return0 ; "not found" +_getenv = return0 ; "not found" diff --git a/libsrc/apple2/joy_stddrv.s b/libsrc/apple2/joy_stddrv.s index 4cab23d40..e4a360dab 100644 --- a/libsrc/apple2/joy_stddrv.s +++ b/libsrc/apple2/joy_stddrv.s @@ -6,9 +6,14 @@ ; const char joy_stddrv[]; ; - .export _joy_stddrv + .export _joy_stddrv .rodata -_joy_stddrv: .asciiz "A2.STDJOY.JOY" +_joy_stddrv: + .ifdef __APPLE2ENH__ + .asciiz "A2E.STDJOY.JOY" + .else + .asciiz "A2.STDJOY.JOY" + .endif diff --git a/libsrc/apple2/kbhit.s b/libsrc/apple2/kbhit.s index 8c6f02158..ac8d85350 100644 --- a/libsrc/apple2/kbhit.s +++ b/libsrc/apple2/kbhit.s @@ -1,18 +1,17 @@ - ;; - ;; Kevin Ruland - ;; - ;; int kbhit (void); - ;; +; +; Kevin Ruland +; Ullrich von Bassewitz, 2005-03-25 +; +; unsigned char kbhit (void); +; - .export _kbhit + .export _kbhit - .import return0, return1 - - .include "apple2.inc" + .include "apple2.inc" -_kbhit: - bit KBD ; Reading keyboard checks for keypress - bmi L1 ; if KBD > 127 key was pressed - jmp return0 -L1: - jmp return1 +_kbhit: lda KBD ; Reading KBD checks for keypress + rol ; if high bit is set, key was pressed + lda #$00 + tax + rol + rts diff --git a/libsrc/apple2/revers.s b/libsrc/apple2/revers.s index acae7c835..2e79e6c8f 100644 --- a/libsrc/apple2/revers.s +++ b/libsrc/apple2/revers.s @@ -1,8 +1,8 @@ - ;; - ;; Kevin Ruland - ;; - ;; unsigned char __fastcall__ revers (unsigned char onoff) - ;; +; +; Kevin Ruland +; +; unsigned char __fastcall__ revers (unsigned char onoff) +; .export _revers @@ -13,13 +13,11 @@ _revers: and #$FF ; Test for any bit beq normal ; Nothing set lda #~$3F ; Not Inverse -normal: - eor #$FF ; Xor Normal +normal: eor #$FF ; Xor Normal sta INVFLG tya ; What was the old value? eor #$FF ; Normal = $FF, Inverse = $3F - beq L2 + beq :+ lda #$01 -L2: +: ldx #$00 rts - diff --git a/libsrc/apple2/rvtabz.s b/libsrc/apple2/rvtabz.s new file mode 100644 index 000000000..eea0ef4f6 --- /dev/null +++ b/libsrc/apple2/rvtabz.s @@ -0,0 +1,9 @@ +; +; Ullrich von Bassewitz, 2004-06-03 +; +; Rom VTABZ routine +; + + .export VTABZ + +VTABZ := $FC24 ; Generate text base address diff --git a/libsrc/apple2/systime.s b/libsrc/apple2/systime.s index 5a90e3e55..5711fccae 100644 --- a/libsrc/apple2/systime.s +++ b/libsrc/apple2/systime.s @@ -9,9 +9,9 @@ ; */ ; - .export __systime + .export __systime - .importzp sreg + .include "zeropage.inc" __systime: lda #$FF diff --git a/libsrc/apple2/textframe.s b/libsrc/apple2/textframe.s new file mode 100644 index 000000000..9ed42cad4 --- /dev/null +++ b/libsrc/apple2/textframe.s @@ -0,0 +1,105 @@ +; +; Oliver Schmidt, 10.03.2004 +; +; void __fastcall__ _textframexy (unsigned char x, unsigned char y, +; unsigned char width, unsigned char height, +; unsigned char style); +; void __fastcall__ _textframe (unsigned char width, unsigned char height); +; unsigned char style); +; + + .export __textframexy, __textframe + .import popa, pusha, _gotoxy + .import chlinedirect, cvlinedirect + + .include "zeropage.inc" + .include "apple2.inc" + +WIDTH = tmp2 +HEIGHT = tmp3 +XORIGIN = tmp4 +YORIGIN = ptr1 + +__textframexy: + sec + bra :+ + +__textframe: + clc +: ldx INVFLG + phx ; Save character display mode + ldx #$FF + stx INVFLG ; Set normal character display mode + pha ; Save index + jsr popa ; Get height + sta HEIGHT + jsr popa ; Get width + sta WIDTH + lda CH + ldx CV + bcc noxy + jsr popa ; Get y + tax + jsr popa ; Get x +noxy: sta XORIGIN + stx YORIGIN + plx ; Restore index +loop: lda XOFFS,x + clc + bpl :+ ; Relative to left edge? + adc WIDTH +: adc XORIGIN + jsr pusha + lda YOFFS,x + clc + bpl :+ ; Relative to top? + adc HEIGHT +: adc YORIGIN + jsr _gotoxy ; Call this one, will pop params + txa + tay + lsr ; Get bit 0 (vline) into carry + lda LENGTH,x + phx ; Save index + ldx CHAR,y + bcc hline + clc + adc HEIGHT + jsr cvlinedirect + bra next +hline: adc WIDTH + jsr chlinedirect +next: plx ; Restore index + inx + txa + and #$03 ; Mask style + bne loop + pla + sta INVFLG ; Restore character display mode + rts + + .rodata + +; 2 styles with 4 lines each make up 8 entries per table +; - even entry numbers mean horizontal lines +; - odd entry numbers mean vertical lines + +; x offset for the line starting point +; - a positive value means relative to the frame left edge +; - a negative value menas relative to the frame right edge +XOFFS: .byte 0, 0, 0, -2, 1, 0, 1, -2 + +; y offset for the line starting point +; - a positive value means relative to the frame top +; - a negative value menas relative to the frame bottom +YOFFS: .byte 0, 1, -2, 1, 0, 0, -2, 0 + +; length of the line relative to the frame size +; - a negative value for hlines means shorter than the width +; - a negative value for vlines menas shorter than the height +LENGTH: .byte 0, -2, 0, -2, -2, 0, -2, 0 + +; character to use for drawing the line +; - hibit set means normal printable character +; - hibit clear means MouseText character +CHAR: .byte '_'|$80, '_', 'L', 'Z', 'L', 'Z', '_'|$80, '_' diff --git a/libsrc/apple2/tgi_mode_table.s b/libsrc/apple2/tgi_mode_table.s index 00bd0ecc4..20d7820a2 100644 --- a/libsrc/apple2/tgi_mode_table.s +++ b/libsrc/apple2/tgi_mode_table.s @@ -4,9 +4,9 @@ ; Apple II mode table for tgi_map_mode ; - .export _tgi_mode_table + .export _tgi_mode_table - .include "tgi-mode.inc" + .include "tgi-mode.inc" ;---------------------------------------------------------------------------- ; Mode table. Contains entries of mode and driver name, the driver name being @@ -17,7 +17,13 @@ .rodata _tgi_mode_table: - .byte TGI_MODE_280_192_6, "A2.HI.TGI", 0 - .byte TGI_MODE_40_40_16, "A2.LO.TGI", 0 -; .byte TGI_MODE_560_192_2, "A2.DHI.TGI", 0 - .byte 0 ; End marker + .ifdef __APPLE2ENH__ + .byte TGI_MODE_280_192_6, "A2E.HI.TGI", 0 + .byte TGI_MODE_40_40_16, "A2E.LO.TGI", 0 +; .byte TGI_MODE_560_192_2, "A2E.DHI.TGI", 0 + .else + .byte TGI_MODE_280_192_6, "A2.HI.TGI", 0 + .byte TGI_MODE_40_40_16, "A2.LO.TGI", 0 +; .byte TGI_MODE_560_192_2, "A2.DHI.TGI", 0 + .endif + .byte 0 ; End marker diff --git a/libsrc/apple2/wherex.s b/libsrc/apple2/wherex.s index 6cf140531..1d67a2fd9 100644 --- a/libsrc/apple2/wherex.s +++ b/libsrc/apple2/wherex.s @@ -1,13 +1,14 @@ +; +; Kevin Ruland +; +; unsigned char wherex (void); +; - ;; Keivn Ruland - ;; - ;; unsigned char wherex( void ); + .export _wherex - .export _wherex - - .include "apple2.inc" + .include "apple2.inc" _wherex: - lda CH + lda CH ldx #$00 - rts + rts diff --git a/libsrc/apple2/wherey.s b/libsrc/apple2/wherey.s index 30612cc77..1ac7b6a75 100644 --- a/libsrc/apple2/wherey.s +++ b/libsrc/apple2/wherey.s @@ -1,13 +1,16 @@ +; +; Kevin Ruland +; +; unsigned char wherey (void); +; - ;; Keivn Ruland - ;; - ;; unsigned char wherey( void ); + .export _wherey - .export _wherey - - .include "apple2.inc" + .include "apple2.inc" _wherey: - lda CV + lda CV + sec + sbc WNDTOP ldx #$00 - rts + rts diff --git a/libsrc/apple2enh/Makefile b/libsrc/apple2enh/Makefile index 49fb853f6..ba7d3a787 100644 --- a/libsrc/apple2enh/Makefile +++ b/libsrc/apple2enh/Makefile @@ -13,17 +13,17 @@ AS = ../../src/ca65/ca65 CC = ../../src/cc65/cc65 LD = ../../src/ld65/ld65 -AFLAGS = -t $(SYS) -I../../asminc -CFLAGS = -Osir -g -T -t $(SYS) --forget-inc-paths -I . -I ../../include +AFLAGS = -t $(SYS) -I../apple2 -I../../asminc +CFLAGS = -Osir -g -T -t $(SYS) --forget-inc-paths -I ../apple2 -I ../../include #-------------------------------------------------------------------------- # Rules -%.o: %.c +%.o: ../apple2/%.c @$(CC) $(CFLAGS) $< @$(AS) -o $@ $(AFLAGS) $(*).s -%.o: %.s +%.o: ../apple2/%.s @$(AS) -g -o $@ $(AFLAGS) $< %.emd: %.o ../runtime/zeropage.o @@ -38,22 +38,51 @@ CFLAGS = -Osir -g -T -t $(SYS) --forget-inc-paths -I . -I ../../include #-------------------------------------------------------------------------- # Object files -OBJS= _scrsize.o \ - chline.o \ +OBJS= _scrsize.o \ + break.o \ + cclear.o \ + cgetc.o \ + chline.o \ + clrscr.o \ + color.o \ cputc.o \ + crt0.o \ + ctype.o \ cvline.o \ - textframe.o + dosdetect.o \ + get_ostype.o \ + getenv.o \ + joy_stddrv.o \ + kbhit.o \ + mainargs.o \ + oserrlist.o \ + randomize.o \ + rcout.o \ + read.o \ + revers.o \ + rhome.o \ + rom.o \ + rpread.o \ + rrdkey.o \ + rvtabz.o \ + systime.o \ + sysuname.o \ + textframe.o \ + tgi_mode_table.o\ + wherex.o \ + wherey.o \ + write.o #-------------------------------------------------------------------------- # Drivers -EMDS = +EMDS = apple2-lc.emd -JOYS = +JOYS = apple2-stdjoy.joy SERS = -TGIS = +TGIS = apple2-40-40-16.tgi apple2-280-192-6.tgi #-------------------------------------------------------------------------- # Targets diff --git a/libsrc/apple2enh/_scrsize.s b/libsrc/apple2enh/_scrsize.s deleted file mode 100644 index 1b020c344..000000000 --- a/libsrc/apple2enh/_scrsize.s +++ /dev/null @@ -1,14 +0,0 @@ -; -; Ullrich von Bassewitz, 26.10.2000 -; -; Screen size variables -; - - .export screensize - - .include "../apple2/apple2.inc" - -screensize: - ldx WNDWDTH - ldy #24 - rts diff --git a/libsrc/apple2enh/chline.s b/libsrc/apple2enh/chline.s deleted file mode 100644 index db5cde9c9..000000000 --- a/libsrc/apple2enh/chline.s +++ /dev/null @@ -1,39 +0,0 @@ -; -; Ullrich von Bassewitz, 08.08.1998 -; -; void chlinexy (unsigned char x, unsigned char y, unsigned char length); -; void chline (unsigned char length); -; - - .export _chlinexy, _chline, chlinedirect - .import popa, _gotoxy, cputdirect - .importzp tmp1 - - .include "../apple2/apple2.inc" - -_chlinexy: - pha ; Save the length - jsr popa ; Get y - jsr _gotoxy ; Call this one, will pop params - pla ; Restore the length and run into _chline - -_chline: - ldx #'S' ; MouseText character - ldy INVFLG - cpy #$FF ; Normal character display mode? - beq chlinedirect - ldx #'-' | $80 ; Horizontal line, screen code - -chlinedirect: - cmp #$00 ; Is the length zero? - beq done ; Jump if done - sta tmp1 -: txa ; Screen code - jsr cputdirect ; Direct output - dec tmp1 - bne :- -done: rts - - - - diff --git a/libsrc/apple2enh/cputc.s b/libsrc/apple2enh/cputc.s deleted file mode 100644 index c82a67d5b..000000000 --- a/libsrc/apple2enh/cputc.s +++ /dev/null @@ -1,89 +0,0 @@ -; -; Ullrich von Bassewitz, 06.08.1998 -; -; void cputcxy (unsigned char x, unsigned char y, char c); -; void cputc (char c); -; - - .constructor initconio - .export _cputcxy, _cputc - .export _gotoxy, cputdirect - .export newline, putchar - - .import popa, SETWND, BASCALC - - .include "../apple2/apple2.inc" - -initconio: - lda #$FF ; Normal character display mode - sta INVFLG - sta SETALTCHAR ; Switch in alternate charset - lda #$00 - jsr SETWND ; Reset text window to full screen - rts - -; Plot a character - also used as internal function - -_cputcxy: - pha ; Save C - jsr popa ; Get Y - jsr _gotoxy - pla ; Restore C - -_cputc: - cmp #$0D ; Test for \r = carrage return - beq left - cmp #$0A ; Test for \n = line feed - beq newline - ora #$80 ; Turn on high bit - -cputdirect: - jsr putchar - inc CH ; Bump to next column - lda CH - cmp WNDWDTH - bne done -left: stz CH ; Goto left edge of screen -done: rts - -newline: - inc CV - lda CV - cmp #24 - bne :+ - lda #$00 - sta CV -: jsr BASCALC - rts - -putchar: - ldy INVFLG - cpy #$FF ; Normal character display mode? - beq put - cmp #$E0 ; Lowercase? - bcc mask - and #$7F ; Inverse lowercase - bra put -mask: and INVFLG ; Apply normal, inverse, flash -put: ldy CH - bit RD80VID ; In 80 column mode? - bpl col40 ; No, in 40 cols - pha - tya - lsr ; Div by 2 - tay - pla - bcs col40 ; Odd cols go in 40 col memory - bit HISCR - sta (BASL),Y - bit LOWSCR - rts -col40: sta (BASL),Y - rts - -_gotoxy: - sta CV ; Store Y - jsr BASCALC - jsr popa ; Get X - sta CH ; Store X - rts diff --git a/libsrc/apple2enh/cvline.s b/libsrc/apple2enh/cvline.s deleted file mode 100644 index ff9704a15..000000000 --- a/libsrc/apple2enh/cvline.s +++ /dev/null @@ -1,30 +0,0 @@ -; -; Ullrich von Bassewitz, 08.08.1998 -; -; void cvlinexy (unsigned char x, unsigned char y, unsigned char length); -; void cvline (unsigned char length); -; - - .export _cvlinexy, _cvline, cvlinedirect - .import popa, _gotoxy, putchar, newline - .importzp tmp1 - -_cvlinexy: - pha ; Save the length - jsr popa ; Get y - jsr _gotoxy ; Call this one, will pop params - pla ; Restore the length and run into _cvline - -_cvline: - ldx #'|' | $80 ; Vertical line, screen code - -cvlinedirect: - cmp #$00 ; Is the length zero? - beq done ; Jump if done - sta tmp1 -: txa ; Screen code - jsr putchar ; Write, no cursor advance - jsr newline ; Advance cursor to next line - dec tmp1 - bne :- -done: rts diff --git a/libsrc/apple2enh/textframe.s b/libsrc/apple2enh/textframe.s deleted file mode 100644 index 9b36dc73b..000000000 --- a/libsrc/apple2enh/textframe.s +++ /dev/null @@ -1,106 +0,0 @@ -; -; Oliver Schmidt, 10.03.2004 -; -; void _textframexy (unsigned char x, unsigned char y, -; unsigned char width, unsigned char height, -; unsigned char style); -; void _textframe (unsigned char width, unsigned char height); -; unsigned char style); -; - - .export __textframexy, __textframe - .import popa, pusha, _gotoxy - .import chlinedirect, cvlinedirect - .importzp tmp2, tmp3, tmp4, ptr1 - - .include "../apple2/apple2.inc" - -WIDTH = tmp2 -HEIGHT = tmp3 -XORIGIN = tmp4 -YORIGIN = ptr1 - -__textframexy: - sec - bra textframe - -__textframe: - clc -textframe: - ldx INVFLG - phx ; Save character display mode - ldx #$FF - stx INVFLG ; Set normal character display mode - pha ; Save index - jsr popa ; Get height - sta HEIGHT - jsr popa ; Get width - sta WIDTH - lda CH - ldx CV - bcc noxy - jsr popa ; Get y - tax - jsr popa ; Get x -noxy: sta XORIGIN - stx YORIGIN - plx ; Restore index -loop: lda XOFFS,x - clc - bpl :+ ; Relative to left edge? - adc WIDTH -: adc XORIGIN - jsr pusha - lda YOFFS,x - clc - bpl :+ ; Relative to top? - adc HEIGHT -: adc YORIGIN - jsr _gotoxy ; Call this one, will pop params - txa - tay - lsr ; Get bit 0 (vline) into carry - lda LENGTH,x - phx ; Save index - ldx CHAR,y - bcc hline - clc - adc HEIGHT - jsr cvlinedirect - bra next -hline: adc WIDTH - jsr chlinedirect -next: plx ; Restore index - inx - txa - and #$03 ; Mask style - bne loop - pla - sta INVFLG ; Restore character display mode - rts - - .rodata - -; 2 styles with 4 lines each make up 8 entries per table -; - even entry numbers mean horizontal lines -; - odd entry numbers mean vertical lines - -; x offset for the line starting point -; - a positive value means relative to the frame left edge -; - a negative value menas relative to the frame right edge -XOFFS: .byte 0, 0, 0, -2, 1, 0, 1, -2 - -; y offset for the line starting point -; - a positive value means relative to the frame top -; - a negative value menas relative to the frame bottom -YOFFS: .byte 0, 1, -2, 1, 0, 0, -2, 0 - -; length of the line relative to the frame size -; - a negative value for hlines means shorter than the width -; - a negative value for vlines menas shorter than the height -LENGTH: .byte 0, -2, 0, -2, -2, 0, -2, 0 - -; character to use for drawing the line -; - hibit set means normal printable character -; - hibit clear means MouseText character -CHAR: .byte '_'|$80, '_', 'L', 'Z', 'L', 'Z', '_'|$80, '_' -- 2.39.5