From 252e4afb9c75b8f4068bfe647ae5a96c5df8f2e3 Mon Sep 17 00:00:00 2001 From: jede Date: Wed, 14 Dec 2016 21:22:10 +0100 Subject: [PATCH 01/29] Adding files for telemon30 --- libsrc/Makefile | 4 +- libsrc/common/fread.s | 12 +- libsrc/telemon30/_open.s | 44 +++ libsrc/telemon30/_read.s | 31 ++ libsrc/telemon30/_scrsize.s | 19 ++ libsrc/telemon30/ch376.s | 200 +++++++++++ libsrc/telemon30/crt0.s | 101 ++++++ libsrc/telemon30/ctype.s | 299 +++++++++++++++++ libsrc/telemon30/graphics.s | 51 +++ libsrc/telemon30/keyboard.s | 13 + libsrc/telemon30/mainargs.s | 137 ++++++++ libsrc/telemon30/mym.s | 626 +++++++++++++++++++++++++++++++++++ libsrc/telemon30/orixhdr.s | 36 ++ libsrc/telemon30/oserrlist.s | 75 +++++ libsrc/telemon30/oserror.s | 17 + libsrc/telemon30/print.s | 21 ++ libsrc/telemon30/sound.s | 45 +++ libsrc/telemon30/sysuname.s | 46 +++ libsrc/telemon30/write.s | 61 ++++ src/ar65.vcxproj | 6 +- src/ca65.vcxproj | 6 +- src/ca65/main.c | 17 +- src/cc65.vcxproj | 6 +- src/cc65/main.c | 10 +- src/chrcvt65.vcxproj | 6 +- src/cl65.vcxproj | 6 +- src/co65.vcxproj | 6 +- src/common.vcxproj | 6 +- src/common/target.c | 8 +- src/common/target.h | 3 +- src/da65.vcxproj | 6 +- src/grc65.vcxproj | 6 +- src/ld65.vcxproj | 6 +- src/od65.vcxproj | 6 +- src/sim65.vcxproj | 6 +- src/sp65.vcxproj | 6 +- 36 files changed, 1899 insertions(+), 55 deletions(-) create mode 100644 libsrc/telemon30/_open.s create mode 100644 libsrc/telemon30/_read.s create mode 100644 libsrc/telemon30/_scrsize.s create mode 100644 libsrc/telemon30/ch376.s create mode 100644 libsrc/telemon30/crt0.s create mode 100644 libsrc/telemon30/ctype.s create mode 100644 libsrc/telemon30/graphics.s create mode 100644 libsrc/telemon30/keyboard.s create mode 100644 libsrc/telemon30/mainargs.s create mode 100644 libsrc/telemon30/mym.s create mode 100644 libsrc/telemon30/orixhdr.s create mode 100644 libsrc/telemon30/oserrlist.s create mode 100644 libsrc/telemon30/oserror.s create mode 100644 libsrc/telemon30/print.s create mode 100644 libsrc/telemon30/sound.s create mode 100644 libsrc/telemon30/sysuname.s create mode 100644 libsrc/telemon30/write.s diff --git a/libsrc/Makefile b/libsrc/Makefile index 99f120f3a..0342a8ca4 100644 --- a/libsrc/Makefile +++ b/libsrc/Makefile @@ -30,7 +30,9 @@ TARGETS = apple2 \ pce \ sim6502 \ sim65c02 \ - supervision + supervision\ + telemon24\ + telemon30 DRVTYPES = emd \ joy \ diff --git a/libsrc/common/fread.s b/libsrc/common/fread.s index 91d692985..b87cc5cb4 100644 --- a/libsrc/common/fread.s +++ b/libsrc/common/fread.s @@ -173,13 +173,16 @@ ; Read was ok, account for the pushed back character (if any). -@L8: add pb +@L8: + add pb bcc @L9 inx ; Check for end of file. -@L9: cmp #0 ; Zero bytes read? +@L9: + + cmp #0 ; Zero bytes read? bne @L10 cpx #0 bne @L10 @@ -192,7 +195,10 @@ ; Return the number of items successfully read. Since we've checked for ; bytes == 0 above, size cannot be zero here, so the division is safe. -@L10: jsr pushax ; Push number of bytes read +@L10: + + + jsr pushax ; Push number of bytes read ldy #5 jsr ldaxysp ; Get size jsr tosudivax ; bytes / size -> a/x diff --git a/libsrc/telemon30/_open.s b/libsrc/telemon30/_open.s new file mode 100644 index 000000000..f308632d9 --- /dev/null +++ b/libsrc/telemon30/_open.s @@ -0,0 +1,44 @@ + .export _open + .import addysp,popax + .importzp sp,tmp2,tmp3,tmp1 + ; int open (const char* name, int flags, ...); /* May take a mode argument */ + .include "telemon30.inc" + +.proc _open +; Throw away any additional parameters passed through the ellipsis + + dey ; Parm count < 4 shouldn't be needed to be... + dey ; ...checked (it generates a c compiler warning) + dey + dey + beq parmok ; Branch if parameter count ok + jsr addysp ; Fix stack, throw away unused parameters + +; Parameters ok. Pop the flags and save them into tmp3 + +parmok: jsr popax ; Get flags + +; Get the filename from stack and parse it. Bail out if is not ok + + jsr popax ; Get name + + + BRK_TELEMON XOPEN + + ; jsr fnparse ; Parse it + ;tax + ;bne oserror ; Bail out if problem with name + +; Get a free file handle and remember it in tmp2 + + ; jsr freefd + ;lda #EMFILE ; Load error code + ;bcs seterrno ; Jump in case of errors + ;stx tmp2 +; + + + rts +.endproc + + \ No newline at end of file diff --git a/libsrc/telemon30/_read.s b/libsrc/telemon30/_read.s new file mode 100644 index 000000000..8f7a20a58 --- /dev/null +++ b/libsrc/telemon30/_read.s @@ -0,0 +1,31 @@ +; +; Ullrich von Bassewitz, 2003-04-13 +; + +; + + .export _read + .import popax + .importzp ptr1, ptr2, ptr3, tmp1, tmp2 + + .include "telemon30.inc" +; int read (int fd, void* buf, unsigned count); + +.proc _read + ;jsr popax ; fp pointer don't care + sta tmp1 ; count + stx tmp2 ; count + jsr popax ; get buf + ;lda #$00 + ;ldx #$a0 + sta PTR_READ_DEST + stx PTR_READ_DEST+1 + lda tmp1 ; + ldy tmp2 ; + BRK_TELEMON XFREAD + + rts + +.endproc + + diff --git a/libsrc/telemon30/_scrsize.s b/libsrc/telemon30/_scrsize.s new file mode 100644 index 000000000..a929f97b1 --- /dev/null +++ b/libsrc/telemon30/_scrsize.s @@ -0,0 +1,19 @@ +; +; 2003-04-13, Ullrich von Bassewitz +; 2013-07-16, Greg King +; +; Screen size variables +; + + .export screensize + .include "telemon30.inc" + +.proc screensize + + ldx #SCREEN_XSIZE + ldy #SCREEN_YSIZE + rts + +.endproc + + diff --git a/libsrc/telemon30/ch376.s b/libsrc/telemon30/ch376.s new file mode 100644 index 000000000..1b75c2b18 --- /dev/null +++ b/libsrc/telemon30/ch376.s @@ -0,0 +1,200 @@ + .export _ch376_set_file_name + .export _ch376_file_open + .export _ch376_ic_get_version + .export _ch376_reset + .export _ch376_check_exist + .export _ch376_disk_mount + + .import popax + .importzp sp,tmp2,tmp3,tmp1 + .include "telemon30.inc" + +; CODE FOR CH376_SET_USB_MODE ************************************************* + +CH376_SET_USB_MODE_CODE_USB_HOST_SOF_PACKAGE_AUTOMATICALLY := $06 + +CH376_USB_INT_DISK_READ := $1d +CH376_USB_INT_SUCCESS := $14 +CH376_ERR_MISS_FILE := $42 + +CH376_DATA :=$340 +CH376_COMMAND :=$341 + +CH376_GET_IC_VER := $01 +CH376_SET_BAUDRATE := $02 +CH376_GET_ENTER_SLEEP := $03 +CH376_RESET_ALL := $05 +CH376_CHECK_EXIST := $06 +CH376_GET_FILE_SIZE := $0C +CH376_SET_USB_MODE := $15 +CH376_GET_STATUS := $22 +CH376_RD_USB_DATA0 := $27 +CH376_SET_FILE_NAME := $2f +CH376_DISK_CONNECT := $30 ; check the disk connection status +CH376_DISK_MOUNT := $31 +CH376_FILE_OPEN := $32 +CH376_FILE_ENUM_GO := $33 +CH376_FILE_CLOSE := $36 +CH376_BYTE_READ := $3A +CH376_BYTE_RD_GO := $3b +CH376_BYTE_WRITE := $3C +CH376_DISK_CAPACITY := $3E +CH376_DISK_RD_GO := $55 + + + +; void ch376_set_file_name(char *filename) +.proc _ch376_set_file_name + sta tmp1 + stx tmp1+1 + lda #CH376_SET_FILE_NAME ;$2f + sta CH376_COMMAND + ldy #0 +loop: + lda (tmp1),y ; replace by bufnom + beq end ; we reached 0 value + sta CH376_DATA + iny + cpy #13 ; because we don't manage longfilename shortname =11 + bne loop +end: + sta CH376_DATA + rts +.endproc + +; void _ch376_file_open(); + +.proc _ch376_file_open + lda #CH376_FILE_OPEN ; $32 + sta CH376_COMMAND + jsr _ch376_wait_response + rts +.endproc + + ;CMD_GET_FILE_SIZE + +.proc _ch376_get_file_size + lda #CH376_GET_FILE_SIZE + sta CH376_COMMAND + lda #$68 + sta CH376_DATA + ; store file leng + lda CH376_DATA + sta tmp1 + lda CH376_DATA + sta tmp1+1 + lda CH376_DATA + sta tmp2 + lda CH376_DATA + sta tmp2+1 + rts +.endproc + +; void ch376_reset(); + +.proc _ch376_reset + lda #CH376_RESET_ALL ; 5 + sta CH376_COMMAND + ; waiting + ldy #0 + ldx #0 +loop: + nop + inx + bne loop + iny + bne loop + rts +.endproc + +; char ch376_check_exist(char value); + +.proc _ch376_check_exist + sta tmp1 + lda #CH376_CHECK_EXIST ; + sta CH376_COMMAND + lda tmp1 + sta CH376_DATA + lda CH376_DATA + rts +.endproc + +; char ch376_ic_get_version(void) +.proc _ch376_ic_get_version + lda #CH376_GET_IC_VER + sta CH376_COMMAND + lda CH376_DATA + rts +.endproc + +; void ch376_set_usb_mode(char mode) + +.proc _ch376_set_usb_mode +; CH376_SET_USB_MODE_CODE_USB_HOST_SOF_PACKAGE_AUTOMATICALLY + sta tmp1 + lda #CH376_SET_USB_MODE ; $15 + sta CH376_COMMAND + lda tmp1 + sta CH376_DATA + rts +.endproc + + +; void ch376_set_bytes_write(int value); +.proc _ch376_set_bytes_write + sta tmp1 + stx tmp1+1 + ldx #CH376_BYTE_WRITE + stx CH376_COMMAND + lda tmp1 + sta CH376_DATA + lda tmp1+1 + sta CH376_DATA + jsr _ch376_wait_response + rts +.endproc + +.proc _ch376_set_bytes_read + ldx #CH376_BYTE_READ + stx CH376_COMMAND + sta CH376_DATA + sty CH376_DATA + jsr _ch376_wait_response + rts +.endproc + +; char ch376_disk_mount(); +.proc _ch376_disk_mount + lda #CH376_DISK_MOUNT ; $31 + sta CH376_COMMAND + jsr _ch376_wait_response + ; if we read data value, we have then length of the volume name + rts +.endproc + + +; char ch376_wait_response(); +.proc _ch376_wait_response +; 1 return 1 if usb controller does not respond +; else A contains answer of the controller + ldy #$ff +loop3: + ldx #$ff ; merci de laisser une valeur importante car parfois en mode non debug, le controleur ne répond pas tout de suite +loop: + lda CH376_COMMAND + and #%10000000 + cmp #128 + bne no_error + dex + bne loop + dey + bne loop3 + ; error is here + rts +no_error: + lda #CH376_GET_STATUS + sta CH376_COMMAND + lda CH376_DATA + rts +.endproc + diff --git a/libsrc/telemon30/crt0.s b/libsrc/telemon30/crt0.s new file mode 100644 index 000000000..72bad5f24 --- /dev/null +++ b/libsrc/telemon30/crt0.s @@ -0,0 +1,101 @@ +; +; Startup code for cc65 (Oric version) +; +; By Debrune Jérôme and Ullrich von Bassewitz +; 2016-03-18, Greg King +; + + .export _exit + .export __STARTUP__ : absolute = 1 ; Mark as startup + + .import initlib, donelib + .import callmain, zerobss + .import __MAIN_START__, __MAIN_SIZE__ + + .include "zeropage.inc" + .include "telemon30.inc" + +; ------------------------------------------------------------------------ +; Place the startup code in a special segment. + +.segment "STARTUP" + + tsx + stx spsave ; Save system stk ptr + +; Save space by putting some of the start-up code in a segment +; that will be re-used. + + jsr init + +; Clear the BSS variables (after the constructors have been run). + + jsr zerobss + +; Push the command-line arguments; and, call main(). + + jsr callmain + +; Call the module destructors. This is also the exit() entry. + +_exit: jsr donelib + +; Restore the system stuff. + + ldx spsave + txs +; lda stsave + ; sta STATUS + +; Copy back the zero-page stuff. + + ldx #zpspace - 1 +L2: lda zpsave,x + sta sp,x + dex + bpl L2 + +; Back to BASIC. + + rts + +; ------------------------------------------------------------------------ +; Put this code in a place that will be re-used by BSS, the heap, +; and the C stack. + +.segment "ONCE" + +; Save the zero-page area that we're about to use. + +init: ldx #zpspace - 1 +L1: lda sp,x + sta zpsave,x + dex + bpl L1 + +; Currently, color isn't supported on the text screen. +; Unprotect screen columns 0 and 1 (where each line's color codes would sit). + + ; lda STATUS + ; sta stsave + ; and #%11011111 + ; sta STATUS + +; Set up the C stack. + + lda #<(__MAIN_START__ + __MAIN_SIZE__) + ldx #>(__MAIN_START__ + __MAIN_SIZE__) + sta sp + stx sp+1 ; Set argument stack ptr + +; Call the module constructors. + + jmp initlib + +; ------------------------------------------------------------------------ + +.segment "INIT" + +spsave: .res 1 +stsave: .res 1 +zpsave: .res zpspace diff --git a/libsrc/telemon30/ctype.s b/libsrc/telemon30/ctype.s new file mode 100644 index 000000000..79edafbb2 --- /dev/null +++ b/libsrc/telemon30/ctype.s @@ -0,0 +1,299 @@ +; +; Ullrich von Bassewitz, 2003-04-13 +; +; Character specification table. +; + +; The tables are readonly, put them into the rodata segment + +.rodata + +; The following 256 byte wide table specifies attributes for the isxxx type +; of functions. Doing it by a table means some overhead in space, but it +; has major advantages: +; +; * It is fast. If it were'nt for the slow parameter passing of cc65, one +; could even define macros for the isxxx functions (this is usually +; done on other platforms). +; +; * It is highly portable. The only unportable part is the table itself, +; all real code goes into the common library. +; +; * We save some code in the isxxx functions. +; +; +; Bit assignments: +; +; 0 - Lower case char +; 1 - Upper case char +; 2 - Numeric digit +; 3 - Hex digit (both, lower and upper) +; 4 - Control character +; 5 - The space character itself +; 6 - Other whitespace (that is: '\f', '\n', '\r', '\t' and '\v') +; 7 - Space or tab character + + .export __ctype + +__ctype: + .byte $10 ; 0/00 ___ctrl_@___ + .byte $10 ; 1/01 ___ctrl_A___ + .byte $10 ; 2/02 ___ctrl_B___ + .byte $10 ; 3/03 ___ctrl_C___ + .byte $10 ; 4/04 ___ctrl_D___ + .byte $10 ; 5/05 ___ctrl_E___ + .byte $10 ; 6/06 ___ctrl_F___ + .byte $10 ; 7/07 ___ctrl_G___ + .byte $10 ; 8/08 ___ctrl_H___ + .byte $D0 ; 9/09 ___ctrl_I___ + .byte $50 ; 10/0a ___ctrl_J___ + .byte $50 ; 11/0b ___ctrl_K___ + .byte $50 ; 12/0c ___ctrl_L___ + .byte $50 ; 13/0d ___ctrl_M___ + .byte $10 ; 14/0e ___ctrl_N___ + .byte $10 ; 15/0f ___ctrl_O___ + .byte $10 ; 16/10 ___ctrl_P___ + .byte $10 ; 17/11 ___ctrl_Q___ + .byte $10 ; 18/12 ___ctrl_R___ + .byte $10 ; 19/13 ___ctrl_S___ + .byte $10 ; 20/14 ___ctrl_T___ + .byte $10 ; 21/15 ___ctrl_U___ + .byte $10 ; 22/16 ___ctrl_V___ + .byte $10 ; 23/17 ___ctrl_W___ + .byte $10 ; 24/18 ___ctrl_X___ + .byte $10 ; 25/19 ___ctrl_Y___ + .byte $10 ; 26/1a ___ctrl_Z___ + .byte $10 ; 27/1b ___ctrl_[___ + .byte $10 ; 28/1c ___ctrl_\___ + .byte $10 ; 29/1d ___ctrl_]___ + .byte $10 ; 30/1e ___ctrl_^___ + .byte $10 ; 31/1f ___ctrl_____ + .byte $A0 ; 32/20 ___SPACE___ + .byte $00 ; 33/21 _____!_____ + .byte $00 ; 34/22 _____"_____ + .byte $00 ; 35/23 _____#_____ + .byte $00 ; 36/24 _____$_____ + .byte $00 ; 37/25 _____%_____ + .byte $00 ; 38/26 _____&_____ + .byte $00 ; 39/27 _____'_____ + .byte $00 ; 40/28 _____(_____ + .byte $00 ; 41/29 _____)_____ + .byte $00 ; 42/2a _____*_____ + .byte $00 ; 43/2b _____+_____ + .byte $00 ; 44/2c _____,_____ + .byte $00 ; 45/2d _____-_____ + .byte $00 ; 46/2e _____._____ + .byte $00 ; 47/2f _____/_____ + .byte $0C ; 48/30 _____0_____ + .byte $0C ; 49/31 _____1_____ + .byte $0C ; 50/32 _____2_____ + .byte $0C ; 51/33 _____3_____ + .byte $0C ; 52/34 _____4_____ + .byte $0C ; 53/35 _____5_____ + .byte $0C ; 54/36 _____6_____ + .byte $0C ; 55/37 _____7_____ + .byte $0C ; 56/38 _____8_____ + .byte $0C ; 57/39 _____9_____ + .byte $00 ; 58/3a _____:_____ + .byte $00 ; 59/3b _____;_____ + .byte $00 ; 60/3c _____<_____ + .byte $00 ; 61/3d _____=_____ + .byte $00 ; 62/3e _____>_____ + .byte $00 ; 63/3f _____?_____ + + .byte $00 ; 64/40 _____@_____ + .byte $0A ; 65/41 _____A_____ + .byte $0A ; 66/42 _____B_____ + .byte $0A ; 67/43 _____C_____ + .byte $0A ; 68/44 _____D_____ + .byte $0A ; 69/45 _____E_____ + .byte $0A ; 70/46 _____F_____ + .byte $02 ; 71/47 _____G_____ + .byte $02 ; 72/48 _____H_____ + .byte $02 ; 73/49 _____I_____ + .byte $02 ; 74/4a _____J_____ + .byte $02 ; 75/4b _____K_____ + .byte $02 ; 76/4c _____L_____ + .byte $02 ; 77/4d _____M_____ + .byte $02 ; 78/4e _____N_____ + .byte $02 ; 79/4f _____O_____ + .byte $02 ; 80/50 _____P_____ + .byte $02 ; 81/51 _____Q_____ + .byte $02 ; 82/52 _____R_____ + .byte $02 ; 83/53 _____S_____ + .byte $02 ; 84/54 _____T_____ + .byte $02 ; 85/55 _____U_____ + .byte $02 ; 86/56 _____V_____ + .byte $02 ; 87/57 _____W_____ + .byte $02 ; 88/58 _____X_____ + .byte $02 ; 89/59 _____Y_____ + .byte $02 ; 90/5a _____Z_____ + .byte $00 ; 91/5b _____[_____ + .byte $00 ; 92/5c _____\_____ + .byte $00 ; 93/5d _____]_____ + .byte $00 ; 94/5e _____^_____ + .byte $00 ; 95/5f _UNDERLINE_ + .byte $00 ; 96/60 ___grave___ + .byte $09 ; 97/61 _____a_____ + .byte $09 ; 98/62 _____b_____ + .byte $09 ; 99/63 _____c_____ + .byte $09 ; 100/64 _____d_____ + .byte $09 ; 101/65 _____e_____ + .byte $09 ; 102/66 _____f_____ + .byte $01 ; 103/67 _____g_____ + .byte $01 ; 104/68 _____h_____ + .byte $01 ; 105/69 _____i_____ + .byte $01 ; 106/6a _____j_____ + .byte $01 ; 107/6b _____k_____ + .byte $01 ; 108/6c _____l_____ + .byte $01 ; 109/6d _____m_____ + .byte $01 ; 110/6e _____n_____ + .byte $01 ; 111/6f _____o_____ + .byte $01 ; 112/70 _____p_____ + .byte $01 ; 113/71 _____q_____ + .byte $01 ; 114/72 _____r_____ + .byte $01 ; 115/73 _____s_____ + .byte $01 ; 116/74 _____t_____ + .byte $01 ; 117/75 _____u_____ + .byte $01 ; 118/76 _____v_____ + .byte $01 ; 119/77 _____w_____ + .byte $01 ; 120/78 _____x_____ + .byte $01 ; 121/79 _____y_____ + .byte $01 ; 122/7a _____z_____ + .byte $00 ; 123/7b _____{_____ + .byte $00 ; 124/7c _____|_____ + .byte $00 ; 125/7d _____}_____ + .byte $00 ; 126/7e _____~_____ + .byte $40 ; 127/7f ____DEL____ + + .byte $00 ; 128/80 ___________ + .byte $00 ; 129/81 ___________ + .byte $00 ; 130/82 ___________ + .byte $00 ; 131/83 ___________ + .byte $00 ; 132/84 ___________ + .byte $00 ; 133/85 ___________ + .byte $00 ; 134/86 ___________ + .byte $00 ; 135/87 ___________ + .byte $00 ; 136/88 ___________ + .byte $00 ; 137/89 ___________ + .byte $00 ; 138/8a ___________ + .byte $00 ; 139/8b ___________ + .byte $00 ; 140/8c ___________ + .byte $00 ; 141/8d ___________ + .byte $00 ; 142/8e ___________ + .byte $00 ; 143/8f ___________ + .byte $00 ; 144/90 ___________ + .byte $00 ; 145/91 ___________ + .byte $00 ; 146/92 ___________ + .byte $10 ; 147/93 ___________ + .byte $00 ; 148/94 ___________ + .byte $00 ; 149/95 ___________ + .byte $00 ; 150/96 ___________ + .byte $00 ; 151/97 ___________ + .byte $00 ; 152/98 ___________ + .byte $00 ; 153/99 ___________ + .byte $00 ; 154/9a ___________ + .byte $00 ; 155/9b ___________ + .byte $00 ; 156/9c ___________ + .byte $00 ; 157/9d ___________ + .byte $00 ; 158/9e ___________ + .byte $00 ; 159/9f ___________ + + .byte $00 ; 160/a0 ___________ + .byte $00 ; 161/a1 ___________ + .byte $00 ; 162/a2 ___________ + .byte $00 ; 163/a3 ___________ + .byte $00 ; 164/a4 ___________ + .byte $00 ; 165/a5 ___________ + .byte $00 ; 166/a6 ___________ + .byte $00 ; 167/a7 ___________ + .byte $00 ; 168/a8 ___________ + .byte $00 ; 169/a9 ___________ + .byte $00 ; 170/aa ___________ + .byte $00 ; 171/ab ___________ + .byte $00 ; 172/ac ___________ + .byte $00 ; 173/ad ___________ + .byte $00 ; 174/ae ___________ + .byte $00 ; 175/af ___________ + .byte $00 ; 176/b0 ___________ + .byte $00 ; 177/b1 ___________ + .byte $00 ; 178/b2 ___________ + .byte $00 ; 179/b3 ___________ + .byte $00 ; 180/b4 ___________ + .byte $00 ; 181/b5 ___________ + .byte $00 ; 182/b6 ___________ + .byte $00 ; 183/b7 ___________ + .byte $00 ; 184/b8 ___________ + .byte $00 ; 185/b9 ___________ + .byte $00 ; 186/ba ___________ + .byte $00 ; 187/bb ___________ + .byte $00 ; 188/bc ___________ + .byte $00 ; 189/bd ___________ + .byte $00 ; 190/be ___________ + .byte $00 ; 191/bf ___________ + + .byte $02 ; 192/c0 ___________ + .byte $02 ; 193/c1 ___________ + .byte $02 ; 194/c2 ___________ + .byte $02 ; 195/c3 ___________ + .byte $02 ; 196/c4 ___________ + .byte $02 ; 197/c5 ___________ + .byte $02 ; 198/c6 ___________ + .byte $02 ; 199/c7 ___________ + .byte $02 ; 200/c8 ___________ + .byte $02 ; 201/c9 ___________ + .byte $02 ; 202/ca ___________ + .byte $02 ; 203/cb ___________ + .byte $02 ; 204/cc ___________ + .byte $02 ; 205/cd ___________ + .byte $02 ; 206/ce ___________ + .byte $02 ; 207/cf ___________ + .byte $02 ; 208/d0 ___________ + .byte $02 ; 209/d1 ___________ + .byte $02 ; 210/d2 ___________ + .byte $02 ; 211/d3 ___________ + .byte $02 ; 212/d4 ___________ + .byte $02 ; 213/d5 ___________ + .byte $02 ; 214/d6 ___________ + .byte $02 ; 215/d7 ___________ + .byte $02 ; 216/d8 ___________ + .byte $02 ; 217/d9 ___________ + .byte $02 ; 218/da ___________ + .byte $02 ; 219/db ___________ + .byte $02 ; 220/dc ___________ + .byte $02 ; 221/dd ___________ + .byte $02 ; 222/de ___________ + .byte $00 ; 223/df ___________ + .byte $01 ; 224/e0 ___________ + .byte $01 ; 225/e1 ___________ + .byte $01 ; 226/e2 ___________ + .byte $01 ; 227/e3 ___________ + .byte $01 ; 228/e4 ___________ + .byte $01 ; 229/e5 ___________ + .byte $01 ; 230/e6 ___________ + .byte $01 ; 231/e7 ___________ + .byte $01 ; 232/e8 ___________ + .byte $01 ; 233/e9 ___________ + .byte $01 ; 234/ea ___________ + .byte $01 ; 235/eb ___________ + .byte $01 ; 236/ec ___________ + .byte $01 ; 237/ed ___________ + .byte $01 ; 238/ee ___________ + .byte $01 ; 239/ef ___________ + .byte $01 ; 240/f0 ___________ + .byte $01 ; 241/f1 ___________ + .byte $01 ; 242/f2 ___________ + .byte $01 ; 243/f3 ___________ + .byte $01 ; 244/f4 ___________ + .byte $01 ; 245/f5 ___________ + .byte $01 ; 246/f6 ___________ + .byte $01 ; 247/f7 ___________ + .byte $01 ; 248/f8 ___________ + .byte $01 ; 249/f9 ___________ + .byte $01 ; 250/fa ___________ + .byte $01 ; 251/fb ___________ + .byte $01 ; 252/fc ___________ + .byte $01 ; 253/fd ___________ + .byte $01 ; 254/fe ___________ + .byte $00 ; 255/ff ___________ + diff --git a/libsrc/telemon30/graphics.s b/libsrc/telemon30/graphics.s new file mode 100644 index 000000000..1d0beefa5 --- /dev/null +++ b/libsrc/telemon30/graphics.s @@ -0,0 +1,51 @@ + .export _paper,_hires,_text,_circle,_curset, _switchOffCursor + .importzp sp,tmp2,tmp3,tmp1 + + .include "telemon30.inc" + +.proc _paper + ldx #0 ; First window + ; A contains the paper + BRK_TELEMON XPAPER + rts +.endproc + +; XINK is bugged, it corrupt memory : removing from export +.proc _ink + ldx #0 ; First window + ; A contains the ink + BRK_TELEMON XINK + rts +.endproc + +; can be optimized with a macro +.proc _hires + BRK_TELEMON XHIRES + rts +.endproc + +.proc _text + BRK_TELEMON XTEXT + rts +.endproc + +.proc _curset + sta HRSX + sty HRSY + BRK_TELEMON XCURSE + rts +.endproc + +.proc _circle + sta HRS1 + BRK_TELEMON XCIRCL + rts +.endproc + +.proc _switchOffCursor + ldx #0 + BRK_TELEMON XCOSCR + rts +.endproc + + diff --git a/libsrc/telemon30/keyboard.s b/libsrc/telemon30/keyboard.s new file mode 100644 index 000000000..974f841e6 --- /dev/null +++ b/libsrc/telemon30/keyboard.s @@ -0,0 +1,13 @@ + .export _key + .importzp sp,tmp2,tmp3,tmp1 + + .include "telemon30.inc" + + +; char key(void); + +.proc _key + BRK_TELEMON XRDW0 ; read keyboard + rts +.endproc + diff --git a/libsrc/telemon30/mainargs.s b/libsrc/telemon30/mainargs.s new file mode 100644 index 000000000..452d0d6d6 --- /dev/null +++ b/libsrc/telemon30/mainargs.s @@ -0,0 +1,137 @@ +; +; 2003-03-07, Ullrich von Bassewitz +; 2011-01-28, Stefan Haubenthal +; 2014-09-10, Greg King +; +; Set up arguments for main +; + + .constructor initmainargs, 24 + .import __argc, __argv + .import ptr1 + .include "telemon30.inc" + .macpack generic + +MAXARGS = 10 ; Maximum number of arguments allowed + + + + + +; Assume that the program was loaded, a moment ago, by the traditional LOAD +; statement. Save the "most-recent filename" as argument #0. +initmainargs: + + ldx #0 ; Limit the length + ; lda #0 ; The terminating NUL character + ; beq L1 ; Branch always +L0: lda BUFEDT,x + beq L3 + cmp #' ' + bne L1 + lda #0 + beq L3 +L1: sta name,x + inx + cpx #FNAME_LEN + bne L0 + lda #0 +L3: + sta name,x + inc __argc ; argc always is equal to, at least, 1 + + + + + + ldy #1 * 2 ; Point to second argv slot + +next: lda BUFEDT,x + beq done ; End of line reached + inx + cmp #' ' ; Skip leading spaces + beq next + + + + + +found: cmp #'"' ; Is the argument quoted? + beq setterm ; Jump if so + dex ; Reset pointer to first argument character + + + lda #' ' ; A space ends the argument +setterm:sta term ; Set end of argument marker + +; Now, store a pointer, to the argument, into the next slot. + + txa ; Get low byte + clc + adc #BUFEDT + ;adc #>args + sta argv+1,y + iny + iny + inc __argc ; Found another arg + +; Search for the end of the argument + + + +argloop:lda BUFEDT,x + beq done + inx + cmp term + bne argloop + +; We've found the end of the argument. X points one character behind it, and +; A contains the terminating character. To make the argument a valid C string, +; replace the terminating character by a zero. + + lda #0 + sta BUFEDT-1,x + +; Check if the maximum number of command line arguments is reached. If not, +; parse the next one. + + lda __argc ; Get low byte of argument count + cmp #MAXARGS ; Maximum number of arguments reached? + bcc next ; Parse next one if not + + + + +done: lda #argv + sta __argv + stx __argv + 1 + rts + + + +.segment "INIT" + +term: .res 1 + + +.data + +name: .res FNAME_LEN + 1 +args: .res SCREEN_XSIZE * 2 - 1 + +ptr_current: + .res 2 +param_found: + .res 1 +; char* argv[MAXARGS+1]={name}; +argv: + .addr name + .res MAXARGS * 2 diff --git a/libsrc/telemon30/mym.s b/libsrc/telemon30/mym.s new file mode 100644 index 000000000..f387f9d64 --- /dev/null +++ b/libsrc/telemon30/mym.s @@ -0,0 +1,626 @@ + .export _Mym_MusicStart + .importzp sp,tmp2,tmp3,tmp1,ptr1 + + .include "telemon30.inc" + +; To check: AYC +; http://cpcwiki.eu/index.php/AYC + + + + +_DecodedByte :=$D0 ; Byte being currently decoded from the MYM stream +_DecodeBitCounter :=$D2 ; Number of bits we can read in the current byte +_DecodedResult :=$D3 ; What is returned by the 'read bits' function +_CurrentAYRegister :=$D4 ; Contains the number of the register being decoded +_RegisterBufferHigh :=$D5 ; Points to the high byte of the decoded register buffer, increment to move to the next register +_BufferFrameOffset :=$D6 ; From 0 to 127, used when filling the decoded register buffer +_MusicResetCounter :=$D7 ; 2 bytes Contains the number of rows to play before reseting +_CurrentFrame :=$D9 ; From 0 to 255 and then cycles... the index of the frame to play this vbl +_PlayerVbl :=$DA +_FrameLoadBalancer :=$DB ; We depack a new frame every 9 VBLs, this way the 14 registers are evenly depacked over 128 frames + + +VIA_1 := $30f +VIA_2 := $30c + +_MusicData := $c000 + +; mym(char *buf) + + + + +; +; Current PSG values during unpacking +; + + +.proc _Mym_MusicStart + + ; The two first bytes of the MYM music is the number of rows in the music + ; We decrement that at each frame, and when we reach zero, time to start again. + sta ptr1 + stx ptr1+1 + + ldy #0 + lda (ptr1),y + sta _MusicResetCounter+0 + iny + lda (ptr1),y + tax + inx + stx _MusicResetCounter+1 + + ;ldx _MusicData+0 + ;stx _MusicResetCounter+0 + ;ldx _MusicData+1 + ;inx + ;stx _MusicResetCounter+1 + + + ; Initialize the read bit counter + ldy #2 ; should be useless because we can do iny which earn 1 byte + + lda ptr1 + clc + adc #2 + bcc next20 + inc ptr1+1 + lda ptr1+1 + sta __auto_music_ptr+2 +next20: + sta ptr1 + sta __auto_music_ptr+1 + + + + ;lda #<(_MusicData+2) + ;sta __auto_music_ptr+1 + ;lda #>(_MusicData+2) + ;sta __auto_music_ptr+2 + + lda #1 + sta _DecodeBitCounter + + ; Clear all data + lda #0 + sta _DecodedResult + sta _DecodedByte + sta _PlayerVbl + sta _PlayerRegCurrentValue + sta _BufferFrameOffset + sta _PlayerCount + sta _CurrentAYRegister + sta _CurrentFrame + + ldx #14 +loop_init: + dex + sta _PlayerRegValues,x + bne loop_init + + + ; + ; Unpack the 128 first register frames + ; + + lda #>_PlayerBuffer + sta _RegisterBufferHigh + + ldx #0 +unpack_block_loop: + stx _CurrentAYRegister + + ; Unpack that register + jsr _PlayerUnpackRegister2 + + ; Next register + ldx _CurrentAYRegister + inx + cpx #14 + bne unpack_block_loop + + + lda #128 + sta _PlayerVbl+0 + + lda #0 + sta _PlayerCount + sta _CurrentAYRegister + sta _CurrentFrame + + lda #9 + sta _FrameLoadBalancer + + lda #1 + sta _MusicPlaying + + ; + ; Install the IRQ + ; + php + sei + lda #<_Mym_PlayFrame + sta _InterruptCallBack_3+1 + lda #>_Mym_PlayFrame + sta _InterruptCallBack_3+2 + plp + + rts + + +_Mym_MusicStop: + + ; Indicate the main code that the music is finished + lda #0 + sta _MusicPlaying + + ; Disable the IRQ so it does not conflict or cause weird things + php + sei + lda #<_DoNothing + sta _InterruptCallBack_3+1 + lda #>_DoNothing + sta _InterruptCallBack_3+2 + plp + + ; Cut the sound so it does not sounds like a dying cat + + ; y=register number + ; x=value to write + ldy #7 ; Control register + ldx #$FF + jsr _PsgPlayRegister + + ldy #8 ; Volume A + ldx #0 + jsr _PsgPlayRegister + + ldy #9 ; Volume B + ldx #0 + jsr _PsgPlayRegister + + ldy #10 ; Volume C + ldx #0 + jsr _PsgPlayRegister + rts + + +_Mym_PlayFrame: + + ; + ; Check for end of music + ; CountZero: $81,$0d + dec _MusicResetCounter+0 + bne music_contines + dec _MusicResetCounter+1 + bne music_contines + +music_resets: + jmp _Mym_MusicStop + +music_contines: + + ; + ; Play a frame of 14 registers + ; + + lda _CurrentFrame + sta _auto_psg_play_read+1 + lda #>_PlayerBuffer + sta _auto_psg_play_read+2 + + ldy #0 +register_loop: + +_auto_psg_play_read: + ldx _PlayerBuffer + + ; y=register number + ; x=value to write + jsr _PsgPlayRegister + + inc _auto_psg_play_read+2 + iny + cpy #14 + bne register_loop + + + + inc _CurrentFrame + inc _PlayerCount + + lda _CurrentAYRegister + cmp #14 + bcs end_reg + + + dec _FrameLoadBalancer + bne end + + jsr _PlayerUnpackRegister + inc _CurrentAYRegister + lda #9 + sta _FrameLoadBalancer +end: + rts + + +end_reg: + + lda _PlayerCount + cmp #128 + bcc skip2 + + lda #0 + sta _CurrentAYRegister + sta _PlayerCount + lda #9 + sta _FrameLoadBalancer + + clc + lda _PlayerVbl+0 + adc #128 + sta _PlayerVbl+0 +skip2: + + + rts + + + +; y=register number +; x=value to write +_PsgPlayRegister: + + sty VIA_1 + txa + + pha + lda VIA_2 + ora #$EE ; $EE 238 11101110 + sta VIA_2 + + and #$11 ; $11 17 00010001 + ora #$CC ; $CC 204 11001100 + sta VIA_2 + + tax + pla + sta VIA_1 + txa + ora #$EC ; $EC 236 11101100 + sta VIA_2 + + and #$11 ; $11 17 00010001 + ora #$CC ; $CC 204 11001100 + sta VIA_2 + + rts + + + + +; +; Initialise X with the number of bits to read +; Y is not modifier +; +_ReadBits: + + lda #0 + sta _DecodedResult + + ; Will iterate X times (number of bits to read) +loop_read_bits: + + dec _DecodeBitCounter + beq get_next_byte + +shift_bit: + asl _DecodedByte + rol _DecodedResult + + dex + bne loop_read_bits + rts + +get_next_byte: + ; reset mask + lda #8 + sta _DecodeBitCounter + + ; fetch a new byte, and increment the adress. +__auto_music_ptr: + lda _MusicData+2 + sta _DecodedByte + + inc __auto_music_ptr+1 + bne shift_bit + inc __auto_music_ptr+2 + jmp shift_bit + + + + + +_PlayerUnpackRegister: + lda #>_PlayerBuffer + clc + adc _CurrentAYRegister + sta _RegisterBufferHigh +_PlayerUnpackRegister2: + ; + ; Init register bit count and current value + ; + ldx _CurrentAYRegister + lda _PlayerRegValues,x + sta _PlayerRegCurrentValue + + + ; + ; Check if it's packed or not + ; and call adequate routine... + ; + ldx #1 + jsr _ReadBits + ldx _DecodedResult + bne DecompressFragment + + +UnchangedFragment: + + ; + ; No change at all, just repeat '_PlayerRegCurrentValue' 128 times + ; + lda _RegisterBufferHigh ; highpart of buffer adress + register number + sta __auto_copy_unchanged_write+2 + + ldx #128 ; 128 iterations + lda _PlayerRegCurrentValue ; Value to write + + ldy _PlayerVbl + +repeat_loop: +__auto_copy_unchanged_write: + sta _PlayerBuffer,y + iny + dex + bne repeat_loop + + + jmp player_main_return + + +player_main_return: + ; Write back register current value + ldx _CurrentAYRegister + lda _PlayerRegCurrentValue + sta _PlayerRegValues,x + + ; Move to the next register buffer + inc _RegisterBufferHigh + rts + + + + +DecompressFragment: + lda _PlayerVbl ; Either 0 or 128 at this point else we have a problem... + sta _BufferFrameOffset + +decompressFragmentLoop: + +player_copy_packed_loop: + ; Check packing method + ldx #1 + jsr _ReadBits + + ldx _DecodedResult + bne PlayerNotCopyLast + +UnchangedRegister: + + ; We just copy the current value 128 times + lda _RegisterBufferHigh ; highpart of buffer adress + register number + sta __auto_player_copy_last+2 + + ldx _BufferFrameOffset ; Value between 00 and 7f + lda _PlayerRegCurrentValue ; Value to copy +__auto_player_copy_last: + sta _PlayerBuffer,x + + inc _BufferFrameOffset + + + +player_return: + + ; Check end of loop + lda _BufferFrameOffset + and #127 + bne decompressFragmentLoop + + jmp player_main_return + + +PlayerNotCopyLast: + ; Check packing method + ldx #1 + jsr _ReadBits + + ldx _DecodedResult + beq DecompressWithOffset + +ReadNewRegisterValue: + ; Read new register value (variable bit count) + ldx _CurrentAYRegister + lda _PlayerRegBits,x + tax + jsr _ReadBits + ldx _DecodedResult + stx _PlayerRegCurrentValue + + ; Copy to stream + lda _RegisterBufferHigh ; highpart of buffer adress + register number + sta __auto_player_read_new+2 + + ldx _BufferFrameOffset ; Value between 00 and 7f + lda _PlayerRegCurrentValue ; New value to write +__auto_player_read_new: + sta _PlayerBuffer,x + + inc _BufferFrameOffset + jmp player_return + + + + +DecompressWithOffset: + + ; Read Offset (0 to 127) + ldx #7 + jsr _ReadBits + + lda _RegisterBufferHigh ; highpart of buffer adress + register number + sta __auto_write+2 ; Write adress + sta __auto_read+2 ; Read adress + + ; Compute wrap around offset... + lda _BufferFrameOffset ; between 0 and 255 + clc + adc _DecodedResult ; + Offset Between 00 and 7f + sec + sbc #128 ; -128 + tay + + ; Read count (7 bits) + ldx #7 + jsr _ReadBits + + inc _DecodedResult ; 1 to 129 + + + ldx _BufferFrameOffset + +player_copy_offset_loop: + +__auto_read: + lda _PlayerBuffer,y ; Y for reading + iny + +__auto_write: + sta _PlayerBuffer,x ; X for writing + + inx + dec _DecodedResult + bne player_copy_offset_loop + + stx _BufferFrameOffset + sta _PlayerRegCurrentValue + + jmp player_return + + + + +; +; Size in bits of each PSG register +; +_PlayerRegBits: + ; Chanel A Frequency + .byt 8 + .byt 4 + + ; Chanel B Frequency + .byt 8 + .byt 4 + + ; Chanel C Frequency + .byt 8 + .byt 4 + + ; Chanel sound generator + .byt 5 + + ; select + .byt 8 + + ; Volume A,B,C + .byt 5 + .byt 5 + .byt 5 + + ; Wave period + .byt 8 + .byt 8 + + ; Wave form + .byt 8 + +_PlayerCount: + .res 1,0 ; must be equal to 0 +_MusicPlaying: + .res 1,0 ; must be equal to 0 + + +_PlayerRegValues: +_RegisterChanAFrequency: + ; Chanel A Frequency + .res 1,8 + .res 1,4 + +_RegisterChanBFrequency: + ; Chanel B Frequency + .res 1,8 + .res 1,4 + +_RegisterChanCFrequency: + ; Chanel C Frequency + .res 1,8 + .res 1,4 + +_RegisterChanNoiseFrequency: + ; Chanel sound generator + .res 1,5 + + ; select + .res 1,8 + + ; Volume A,B,C +_RegisterChanAVolume: + .res 1,5 +_RegisterChanBVolume: + .res 1,5 +_RegisterChanCVolume: + .res 1,5 + + ; Wave period + .res 1,8 + .res 1,8 + + ; Wave form + .res 1,8 + +_PlayerRegCurrentValue: + .res 1,0 +_DoNothing: + rts + +_InterruptCallBack_3: ; Used by the music player + jsr _DoNothing ; Transformed to "jsr _Mym_PlayFrame" -> 12 cycles + +; jsr MiniScrollLoading ; -> 338 cycles + + pla + tay + pla + tax + pla + + rti +_PlayerBuffer: + .res 256*14 ; About 3.5 kilobytes somewhere in memory, we put the music file in overlay memory + +.endproc + diff --git a/libsrc/telemon30/orixhdr.s b/libsrc/telemon30/orixhdr.s new file mode 100644 index 000000000..8744e86b0 --- /dev/null +++ b/libsrc/telemon30/orixhdr.s @@ -0,0 +1,36 @@ +; +; Based on code by Debrune Jérôme +; 2016-03-17, Greg King +; + + ; The following symbol is used by the linker config. file + ; to force this module to be included into the output file. + .export __ORIXHDR__:abs = 1 + + ; These symbols, also, come from the configuration file. + .import __AUTORUN__, __PROGFLAG__ + .import __BASHEAD_START__, __MAIN_LAST__ + + +; ------------------------------------------------------------------------ +; Oric cassette-tape header + +.segment "ORIXHDR" + + .byte $01, $00 ; + + .byte "ORI" + + .byte $01 ; version + .byte $00,$00 ; mode + .byte $00,$00 ; cpu type + .byte $00,$00 ; OS + + .byte $00 ; reserved + .byte $00 ; auto + + + .word __BASHEAD_START__ ; Address of start of file + .word __MAIN_LAST__ - 1 ; Address of end of file + .word __BASHEAD_START__ ; Address of start of file + diff --git a/libsrc/telemon30/oserrlist.s b/libsrc/telemon30/oserrlist.s new file mode 100644 index 000000000..8ec41de6d --- /dev/null +++ b/libsrc/telemon30/oserrlist.s @@ -0,0 +1,75 @@ +; +; Stefan Haubenthal, 2004-05-25 +; Ullrich von Bassewitz, 18.07.2002 +; +; Defines the platform specific error list. +; +; The table is built as a list of entries +; +; .byte entrylen +; .byte errorcode +; .asciiz errormsg +; +; and terminated by an entry with length zero that is returned if the +; error code could not be found. +; + + .export __sys_oserrlist + +;---------------------------------------------------------------------------- +; Macros used to generate the list (may get moved to an include file?) + +; Regular entry +.macro sys_oserr_entry code, msg + .local Start, End +Start: .byte End - Start + .byte code + .asciiz msg +End: +.endmacro + +; Sentinel entry +.macro sys_oserr_sentinel msg + .byte 0 ; Length is always zero + .byte 0 ; Code is unused + .asciiz msg +.endmacro + +;---------------------------------------------------------------------------- +; The error message table + +.rodata + +__sys_oserrlist: + sys_oserr_entry 1, "File not found" + sys_oserr_entry 2, "Invalid command end" + sys_oserr_entry 3, "No drive number" + sys_oserr_entry 4, "Bad drive number" + sys_oserr_entry 5, "Invalid filename" + sys_oserr_entry 6, "fderr=(error number)" + sys_oserr_entry 7, "Illegal attribute" + sys_oserr_entry 8, "Wildcard(s) not allowed" + sys_oserr_entry 9, "File already exists" + sys_oserr_entry 10, "Insufficient disc space" + sys_oserr_entry 11, "File open" + sys_oserr_entry 12, "Illegal quantity" + sys_oserr_entry 13, "End address missing" + sys_oserr_entry 14, "Start address > end address" + sys_oserr_entry 15, "Missing 'to'" + sys_oserr_entry 16, "Renamed file not on same disc" + sys_oserr_entry 17, "Unknown array" + sys_oserr_entry 18, "Target drive not source drive" + sys_oserr_entry 19, "Destination not specified" + sys_oserr_entry 20, "Cannot merge and overwrite" + sys_oserr_entry 21, "Single target file illegal" + sys_oserr_entry 22, "Syntax" + sys_oserr_entry 23, "Filename missing" + sys_oserr_entry 24, "Source file missing" + sys_oserr_entry 25, "Type mismatch" + sys_oserr_entry 26, "Disc write-protected" + sys_oserr_entry 27, "Incompatible drives" + sys_oserr_entry 28, "File not open" + sys_oserr_entry 29, "File end" + sys_oserr_sentinel "Unknown error" + + diff --git a/libsrc/telemon30/oserror.s b/libsrc/telemon30/oserror.s new file mode 100644 index 000000000..37c9bd7fc --- /dev/null +++ b/libsrc/telemon30/oserror.s @@ -0,0 +1,17 @@ +; +; Stefan Haubenthal, 2011-04-18 +; +; int __fastcall__ _osmaperrno (unsigned char oserror); +; /* Map a system specific error into a system independent code */ +; + + .include "errno.inc" + .export __osmaperrno + +.proc __osmaperrno + + lda #EUNKNOWN + rts + +.endproc diff --git a/libsrc/telemon30/print.s b/libsrc/telemon30/print.s new file mode 100644 index 000000000..56c513fd6 --- /dev/null +++ b/libsrc/telemon30/print.s @@ -0,0 +1,21 @@ +; +; Jede +; +; print (char * str); +; +; This function is a hack! +; + + .export _print + .import popax + .importzp tmp1 + .include "telemon30.inc" + +.proc _print + stx tmp1 + ldy tmp1 + BRK_TELEMON XWSTR0 + rts +.endproc + + diff --git a/libsrc/telemon30/sound.s b/libsrc/telemon30/sound.s new file mode 100644 index 000000000..2df18f4a0 --- /dev/null +++ b/libsrc/telemon30/sound.s @@ -0,0 +1,45 @@ + .export _kbdclick1,_oups,_ping,_explode,_shoot,_zap + .include "telemon30.inc" + +.proc _kbdclick1 + LDX #sound_bip_keyboard + BRK_TELEMON XSONPS + rts +sound_bip_keyboard: + .byte $1f,$00,$00,$00,$00,$00,$00,$3e,$10,$00,$00,$1f,$00,$00 +.endproc + +.proc _explode + BRK_TELEMON XEXPLO + rts +.endproc + +.proc _oups + BRK_TELEMON XOUPS + rts +.endproc + +.proc _ping + BRK_TELEMON XPING + rts +.endproc + +.proc _shoot + BRK_TELEMON XSHOOT + rts +.endproc + +.proc _zap + BRK_TELEMON XZAP + rts +.endproc + + + +; XPLAY := $43 +; XSOUND := $44 +; XMUSIC := $45 + + + diff --git a/libsrc/telemon30/sysuname.s b/libsrc/telemon30/sysuname.s new file mode 100644 index 000000000..51af1d8fe --- /dev/null +++ b/libsrc/telemon30/sysuname.s @@ -0,0 +1,46 @@ +; +; Ullrich von Bassewitz, 2003-08-12 +; +; unsigned char __fastcall__ _sysuname (struct utsname* buf); +; + + .export __sysuname, utsdata + + .import utscopy + + __sysuname = utscopy + +;-------------------------------------------------------------------------- +; Data. We define a fixed utsname struct here and just copy it. + +.rodata + +utsdata: + ; sysname + .asciiz "cc65" + + ; nodename + .asciiz "" + + ; release + .byte ((.VERSION >> 8) & $0F) + '0' + .byte '.' + .if ((.VERSION >> 4) & $0F) > 9 + .byte ((.VERSION >> 4) & $0F) / 10 + '0' + .byte ((.VERSION >> 4) & $0F) .MOD 10 + '0' + .else + .byte ((.VERSION >> 4) & $0F) + '0' + .endif + .byte $00 + + ; version + .if (.VERSION & $0F) > 9 + .byte (.VERSION & $0F) / 10 + '0' + .byte (.VERSION & $0F) .MOD 10 + '0' + .else + .byte (.VERSION & $0F) + '0' + .endif + .byte $00 + + ; machine + .asciiz "Oric Telestrat" diff --git a/libsrc/telemon30/write.s b/libsrc/telemon30/write.s new file mode 100644 index 000000000..32965fe3d --- /dev/null +++ b/libsrc/telemon30/write.s @@ -0,0 +1,61 @@ +; +; Ullrich von Bassewitz, 2003-04-13 +; +; int write (int fd, const void* buf, int count); +; +; This function is a hack! +; + + .export _write + .import popax + .importzp ptr1, ptr2, ptr3, tmp1 + + .include "telemon30.inc" + +.proc _write + + sta ptr3 + stx ptr3+1 ; save count as result + + eor #$FF + sta ptr2 + txa + eor #$FF + sta ptr2+1 ; Remember -count-1 + + jsr popax ; get buf + sta ptr1 + stx ptr1+1 + jsr popax ; get fd and discard +L1: inc ptr2 + bne L2 + inc ptr2+1 + beq L9 +L2: ldy #0 + lda (ptr1),y + tax + cpx #$0A ; Check for \n + bne L3 + BRK_TELEMON XWR0 ; Macro + lda #$0d ; return to the beggining of the line + BRK_TELEMON XWR0 ; Macro ; + + + ldx #$0D +L3: + BRK_TELEMON XWR0 ; Macro + + inc ptr1 + bne L1 + inc ptr1+1 + jmp L1 + +; No error, return count + +L9: lda ptr3 + ldx ptr3+1 + rts + +.endproc + + diff --git a/src/ar65.vcxproj b/src/ar65.vcxproj index b077134ce..003a5fa69 100644 --- a/src/ar65.vcxproj +++ b/src/ar65.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -18,12 +18,12 @@ true - v120 + v140 false true - v120 + v140 diff --git a/src/ca65.vcxproj b/src/ca65.vcxproj index 4e02fa2a9..fb7cf2e26 100644 --- a/src/ca65.vcxproj +++ b/src/ca65.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -18,12 +18,12 @@ true - v120 + v140 false true - v120 + v140 diff --git a/src/ca65/main.c b/src/ca65/main.c index d6c364e4b..4aa60f2f0 100644 --- a/src/ca65/main.c +++ b/src/ca65/main.c @@ -226,10 +226,6 @@ static void SetSys (const char* Sys) CBMSystem ("__C64__"); break; - case TGT_C65: - CBMSystem ("__C65__"); - break; - case TGT_VIC20: CBMSystem ("__VIC20__"); break; @@ -289,7 +285,15 @@ static void SetSys (const char* Sys) case TGT_ATMOS: NewSymbol ("__ATMOS__", 1); - break; + break; + + case TGT_TELEMON24: + NewSymbol ("__TELEMON24__", 1); + break; + + case TGT_TELEMON30: + NewSymbol ("__TELEMON30__", 1); + break; case TGT_NES: NewSymbol ("__NES__", 1); @@ -623,8 +627,7 @@ static void OptVersion (const char* Opt attribute ((unused)), const char* Arg attribute ((unused))) /* Print the assembler version */ { - fprintf (stderr, "%s V%s\n", ProgName, GetVersionAsString ()); - exit(EXIT_SUCCESS); + fprintf (stderr, "ca65 V%s\n", GetVersionAsString ()); } diff --git a/src/cc65.vcxproj b/src/cc65.vcxproj index 1c1f993fe..aa85b0936 100644 --- a/src/cc65.vcxproj +++ b/src/cc65.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -18,12 +18,12 @@ true - v120 + v140 false true - v120 + v140 diff --git a/src/cc65/main.c b/src/cc65/main.c index afbec43d7..f25a44d69 100644 --- a/src/cc65/main.c +++ b/src/cc65/main.c @@ -243,6 +243,14 @@ static void SetSys (const char* Sys) DefineNumericMacro ("__ATMOS__", 1); break; + case TGT_TELEMON24: + DefineNumericMacro ("__TELEMON24__", 1); + break; + + case TGT_TELEMON30: + DefineNumericMacro ("__TELEMON30__", 1); + break; + case TGT_NES: DefineNumericMacro ("__NES__", 1); break; @@ -742,7 +750,7 @@ static void OptVersion (const char* Opt attribute ((unused)), const char* Arg attribute ((unused))) /* Print the compiler version */ { - fprintf (stderr, "%s V%s\n", ProgName, GetVersionAsString ()); + fprintf (stderr, "cc65 V%s\n", GetVersionAsString ()); exit (EXIT_SUCCESS); } diff --git a/src/chrcvt65.vcxproj b/src/chrcvt65.vcxproj index 1daf7cae9..d120399d1 100644 --- a/src/chrcvt65.vcxproj +++ b/src/chrcvt65.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -18,12 +18,12 @@ true - v120 + v140 false true - v120 + v140 diff --git a/src/cl65.vcxproj b/src/cl65.vcxproj index 64c1126b1..b6ceb161a 100644 --- a/src/cl65.vcxproj +++ b/src/cl65.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -18,12 +18,12 @@ true - v120 + v140 false true - v120 + v140 diff --git a/src/co65.vcxproj b/src/co65.vcxproj index c66c8aac8..89eed36e1 100644 --- a/src/co65.vcxproj +++ b/src/co65.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -18,12 +18,12 @@ true - v120 + v140 false true - v120 + v140 diff --git a/src/common.vcxproj b/src/common.vcxproj index 053d23981..c466d9712 100644 --- a/src/common.vcxproj +++ b/src/common.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -113,13 +113,13 @@ StaticLibrary true - v120 + v140 false true StaticLibrary - v120 + v140 diff --git a/src/common/target.c b/src/common/target.c index 99a134c43..adbc080bf 100644 --- a/src/common/target.c +++ b/src/common/target.c @@ -147,12 +147,11 @@ static const TargetEntry TargetMap[] = { { "atari", TGT_ATARI }, { "atari5200", TGT_ATARI5200 }, { "atarixl", TGT_ATARIXL }, - { "atmos", TGT_ATMOS }, + { "atmos", TGT_ATMOS }, { "bbc", TGT_BBC }, { "c128", TGT_C128 }, { "c16", TGT_C16 }, { "c64", TGT_C64 }, - { "c65", TGT_C65 }, { "cbm510", TGT_CBM510 }, { "cbm610", TGT_CBM610 }, { "gamate", TGT_GAMATE }, @@ -171,6 +170,8 @@ static const TargetEntry TargetMap[] = { { "sim6502", TGT_SIM6502 }, { "sim65c02", TGT_SIM65C02 }, { "supervision", TGT_SUPERVISION }, + { "telemon24", TGT_TELEMON24 }, + { "telemon30", TGT_TELEMON30 }, { "vic20", TGT_VIC20 }, }; #define MAP_ENTRY_COUNT (sizeof (TargetMap) / sizeof (TargetMap[0])) @@ -199,6 +200,8 @@ static const TargetProperties PropertyTable[TGT_COUNT] = { { "geos-apple", CPU_65C02, BINFMT_BINARY, CTNone }, { "lunix", CPU_6502, BINFMT_O65, CTNone }, { "atmos", CPU_6502, BINFMT_BINARY, CTNone }, + { "telemon24", CPU_6502, BINFMT_BINARY, CTNone }, + { "telemon30", CPU_6502, BINFMT_BINARY, CTNone }, { "nes", CPU_6502, BINFMT_BINARY, CTNone }, { "supervision", CPU_65SC02, BINFMT_BINARY, CTNone }, { "lynx", CPU_65SC02, BINFMT_BINARY, CTNone }, @@ -206,7 +209,6 @@ static const TargetProperties PropertyTable[TGT_COUNT] = { { "sim65c02", CPU_65C02, BINFMT_BINARY, CTNone }, { "pce", CPU_HUC6280, BINFMT_BINARY, CTNone }, { "gamate", CPU_6502, BINFMT_BINARY, CTNone }, - { "c65", CPU_4510, BINFMT_BINARY, CTPET }, }; /* Target system */ diff --git a/src/common/target.h b/src/common/target.h index 4115ae21a..4bc00225d 100644 --- a/src/common/target.h +++ b/src/common/target.h @@ -73,6 +73,8 @@ typedef enum { TGT_GEOS_APPLE, TGT_LUNIX, TGT_ATMOS, + TGT_TELEMON24, + TGT_TELEMON30, TGT_NES, TGT_SUPERVISION, TGT_LYNX, @@ -80,7 +82,6 @@ typedef enum { TGT_SIM65C02, TGT_PCENGINE, TGT_GAMATE, - TGT_C65, TGT_COUNT /* Number of target systems */ } target_t; diff --git a/src/da65.vcxproj b/src/da65.vcxproj index 7810844dc..cf297fd32 100644 --- a/src/da65.vcxproj +++ b/src/da65.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -18,12 +18,12 @@ true - v120 + v140 false true - v120 + v140 diff --git a/src/grc65.vcxproj b/src/grc65.vcxproj index 211ad7cce..afac0cce1 100644 --- a/src/grc65.vcxproj +++ b/src/grc65.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -18,12 +18,12 @@ true - v120 + v140 false true - v120 + v140 diff --git a/src/ld65.vcxproj b/src/ld65.vcxproj index acb9b4240..cc5598aad 100644 --- a/src/ld65.vcxproj +++ b/src/ld65.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -18,12 +18,12 @@ true - v120 + v140 false true - v120 + v140 diff --git a/src/od65.vcxproj b/src/od65.vcxproj index c788ac961..2ace26001 100644 --- a/src/od65.vcxproj +++ b/src/od65.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -18,12 +18,12 @@ true - v120 + v140 false true - v120 + v140 diff --git a/src/sim65.vcxproj b/src/sim65.vcxproj index f87b4db6b..9ba0980ba 100644 --- a/src/sim65.vcxproj +++ b/src/sim65.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -18,12 +18,12 @@ true - v120 + v140 false true - v120 + v140 diff --git a/src/sp65.vcxproj b/src/sp65.vcxproj index 8db98346c..6e7d992d4 100644 --- a/src/sp65.vcxproj +++ b/src/sp65.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -18,12 +18,12 @@ true - v120 + v140 false true - v120 + v140 From 15ac85b50c4aa6d32966cfeec5bc650c037aa0c1 Mon Sep 17 00:00:00 2001 From: jede Date: Wed, 14 Dec 2016 23:45:20 +0100 Subject: [PATCH 02/29] Adding ch376.h header, correcting some bugs --- include/ch376.h | 55 ++++++++++++++++++++++++++++++++++++++++ libsrc/telemon30/ch376.s | 8 +++--- 2 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 include/ch376.h diff --git a/include/ch376.h b/include/ch376.h new file mode 100644 index 000000000..9db801eaf --- /dev/null +++ b/include/ch376.h @@ -0,0 +1,55 @@ + + +/* /// "Portable types" */ + + + + +/* /// "CH376 interface commands and constants" */ + +// Chip version +#define CH376_DATA_IC_VER 3 + +// Commands +#define CH376_CMD_NONE 0x00 +#define CH376_CMD_GET_IC_VER 0x01 +#define CH376_CMD_CHECK_EXIST 0x06 +#define CH376_CMD_SET_USB_MODE 0x15 +#define CH376_CMD_GET_STATUS 0x22 +#define CH376_CMD_RD_USB_DATA0 0x27 +#define CH376_CMD_WR_REQ_DATA 0x2d +#define CH376_CMD_SET_FILE_NAME 0x2f +#define CH376_CMD_DISK_MOUNT 0x31 +#define CH376_CMD_FILE_OPEN 0x32 +#define CH376_CMD_FILE_ENUM_GO 0x33 +#define CH376_CMD_FILE_CREATE 0x34 +#define CH376_CMD_FILE_CLOSE 0x36 +#define CH376_CMD_BYTE_LOCATE 0x39 +#define CH376_CMD_BYTE_READ 0x3a +#define CH376_CMD_BYTE_RD_GO 0x3b +#define CH376_CMD_BYTE_WRITE 0x3c +#define CH376_CMD_BYTE_WR_GO 0x3d +#define CH376_CMD_DISK_QUERY 0x3f +#define CH376_CMD_DISK_RD_GO 0x55 + +#define CH376_ARG_SET_USB_MODE_INVALID 0x00 +#define CH376_ARG_SET_USB_MODE_SD_HOST 0x03 +#define CH376_ARG_SET_USB_MODE_USB_HOST 0x06 + +// Status & errors +#define CH376_ERR_OPEN_DIR 0x41 +#define CH376_ERR_MISS_FILE 0x42 + +#define CH376_RET_SUCCESS 0x51 +#define CH376_RET_ABORT 0x5f + +#define CH376_INT_SUCCESS 0x14 +#define CH376_INT_DISK_READ 0x1d +#define CH376_INT_DISK_WRITE 0x1e + + +unsigned char ch376_check_exist(unsigned char value); +unsigned char ch376_ic_get_version(void); +void ch376_set_usb_mode(unsigned char value); +unsigned char ch376_disk_mount(void); + diff --git a/libsrc/telemon30/ch376.s b/libsrc/telemon30/ch376.s index 1b75c2b18..90e2878e1 100644 --- a/libsrc/telemon30/ch376.s +++ b/libsrc/telemon30/ch376.s @@ -4,7 +4,7 @@ .export _ch376_reset .export _ch376_check_exist .export _ch376_disk_mount - + .export _ch376_set_usb_mode .import popax .importzp sp,tmp2,tmp3,tmp1 .include "telemon30.inc" @@ -123,6 +123,7 @@ loop: .proc _ch376_ic_get_version lda #CH376_GET_IC_VER sta CH376_COMMAND + ldx #0 lda CH376_DATA rts .endproc @@ -131,10 +132,10 @@ loop: .proc _ch376_set_usb_mode ; CH376_SET_USB_MODE_CODE_USB_HOST_SOF_PACKAGE_AUTOMATICALLY - sta tmp1 + pha lda #CH376_SET_USB_MODE ; $15 sta CH376_COMMAND - lda tmp1 + pla sta CH376_DATA rts .endproc @@ -169,6 +170,7 @@ loop: sta CH376_COMMAND jsr _ch376_wait_response ; if we read data value, we have then length of the volume name + ldx #0 rts .endproc From d5ba0636027feab064614b669c9196ef24ed6287 Mon Sep 17 00:00:00 2001 From: jede Date: Wed, 4 Jan 2017 20:03:19 +0100 Subject: [PATCH 03/29] Correcting some bugs --- include/telemon.h | 58 ++++++++++++++++++++++++++++++++++++++++ libsrc/telemon30/_open.s | 28 ++++++++++++++++--- libsrc/telemon30/ch376.s | 27 +++++++++++++++++-- 3 files changed, 108 insertions(+), 5 deletions(-) create mode 100644 include/telemon.h diff --git a/include/telemon.h b/include/telemon.h new file mode 100644 index 000000000..70033a9ad --- /dev/null +++ b/include/telemon.h @@ -0,0 +1,58 @@ + +void print (char *); + +void hires(); +void text(); +void oups(); +void ping(); +void zap(); +void shoot(); +void explode(); + +void paper(char color); +void ink(char color); + +void kbdclick1(); + + + +void curset(char x,char y); +void circle(char rayon); + +char key(void); + + +/* PEEK, POKE, DEEK, DOKE */ + +#define POKE(addr,val) (*(unsigned char*) (addr) = (val)) + + +#define PCHN_1 001 +#define PCHN_2 002 +#define PCHN_12 003 +#define PCHN_3 004 +#define PCHN_13 005 +#define PCHN_23 006 +#define PCHN_123 007 + +#define ENV_DECAY 001 /* \_________ envelope */ +#define ENV_ATTACK_CUT 002 /* /_________ envelope */ +#define ENV_SAW_DOWN 003 /* \\\\\\\\\\ envelope */ +#define ENV_WAVE 004 /* /\/\/\/\/\ envelope */ +#define ENV_DECAY_CONT 005 /* \~~~~~~~~~ envelope */ +#define ENV_SAW_UP 006 /* ////////// envelope */ +#define ENV_ATTACK_CONT 007 /* /~~~~~~~~~ envelope */ + +#define VOL_ENVELOPE 0x0 +#define VOL_QUIETEST 0x1 +#define VOL_LOUDEST 0xe + +extern int play(int soundchanels,int noisechanels,int envelop,int volume); + + +/* Play a musical tone through the selected channel. */ + +#define CHAN_1 1 +#define CHAN_2 2 +#define CHAN_3 3 + diff --git a/libsrc/telemon30/_open.s b/libsrc/telemon30/_open.s index f308632d9..a002bbce1 100644 --- a/libsrc/telemon30/_open.s +++ b/libsrc/telemon30/_open.s @@ -3,7 +3,9 @@ .importzp sp,tmp2,tmp3,tmp1 ; int open (const char* name, int flags, ...); /* May take a mode argument */ .include "telemon30.inc" - + .include "errno.inc" + .include "fcntl.inc" + .proc _open ; Throw away any additional parameters passed through the ellipsis @@ -16,12 +18,32 @@ ; Parameters ok. Pop the flags and save them into tmp3 -parmok: jsr popax ; Get flags +parmok: jsr popax ; Get flagss + sta tmp3 ; save flags + + ;AND #O_RDONLY + ;beq READONLY + ;lda tmp3 + ;AND #O_WRONLY + ;beq WRITEONLY + ;jmp next +;READONLY: +; lda #'r' +; BRK_TELEMON XWR0 +; jmp next +;WRITEONLY: +; lda #'w' +; BRK_TELEMON XWR0 + +;next: ; Get the filename from stack and parse it. Bail out if is not ok jsr popax ; Get name - + + + ldy tmp3 ; Get flags + BRK_TELEMON XOPEN diff --git a/libsrc/telemon30/ch376.s b/libsrc/telemon30/ch376.s index 90e2878e1..24df14471 100644 --- a/libsrc/telemon30/ch376.s +++ b/libsrc/telemon30/ch376.s @@ -1,3 +1,6 @@ + + ; For XA65 compatibily in the futur + .FEATURE c_comments,labels_without_colons,pc_assignment, loose_char_term .export _ch376_set_file_name .export _ch376_file_open .export _ch376_ic_get_version @@ -5,10 +8,18 @@ .export _ch376_check_exist .export _ch376_disk_mount .export _ch376_set_usb_mode + .export _ch376_file_create + .export _ch376_fcreate + + ; High level function + .export _ch376_fcreate + .import popax .importzp sp,tmp2,tmp3,tmp1 .include "telemon30.inc" +/* +*/ ; CODE FOR CH376_SET_USB_MODE ************************************************* CH376_SET_USB_MODE_CODE_USB_HOST_SOF_PACKAGE_AUTOMATICALLY := $06 @@ -17,8 +28,7 @@ CH376_USB_INT_DISK_READ := $1d CH376_USB_INT_SUCCESS := $14 CH376_ERR_MISS_FILE := $42 -CH376_DATA :=$340 -CH376_COMMAND :=$341 + CH376_GET_IC_VER := $01 CH376_SET_BAUDRATE := $02 @@ -34,6 +44,7 @@ CH376_DISK_CONNECT := $30 ; check the disk connection status CH376_DISK_MOUNT := $31 CH376_FILE_OPEN := $32 CH376_FILE_ENUM_GO := $33 +CH376_FILE_CREATE := $34 CH376_FILE_CLOSE := $36 CH376_BYTE_READ := $3A CH376_BYTE_RD_GO := $3b @@ -41,7 +52,19 @@ CH376_BYTE_WRITE := $3C CH376_DISK_CAPACITY := $3E CH376_DISK_RD_GO := $55 +.proc _ch376_file_create + lda #CH376_FILE_CREATE + sta CH376_COMMAND + jsr _ch376_wait_response + rts +.endproc +; void _ch376_fcreate(char *filename) +.proc _ch376_fcreate + jsr _ch376_set_file_name + jsr _ch376_file_open + jsr _ch376_file_create +.endproc ; void ch376_set_file_name(char *filename) .proc _ch376_set_file_name From 038ac5a65a1f56af105635ceb2065af0a1a53ec0 Mon Sep 17 00:00:00 2001 From: jede Date: Sun, 22 Jan 2017 21:41:49 +0100 Subject: [PATCH 04/29] Correcting doc adding telemon 2.4 primitives --- doc/telemon24.sgml | 42 +++++ doc/telemon30.sgml | 177 +++++++++++++++++++++ libsrc/telemon24/_scrsize.s | 19 +++ libsrc/telemon24/crt0.s | 101 ++++++++++++ libsrc/telemon24/ctype.s | 299 +++++++++++++++++++++++++++++++++++ libsrc/telemon24/hires.s | 22 +++ libsrc/telemon24/mainargs.s | 36 +++++ libsrc/telemon24/oserrlist.s | 75 +++++++++ libsrc/telemon24/oserror.s | 17 ++ libsrc/telemon24/print.s | 25 +++ libsrc/telemon24/sysuname.s | 46 ++++++ libsrc/telemon24/tapehdr.s | 36 +++++ libsrc/telemon24/write.s | 59 +++++++ 13 files changed, 954 insertions(+) create mode 100644 doc/telemon24.sgml create mode 100644 doc/telemon30.sgml create mode 100644 libsrc/telemon24/_scrsize.s create mode 100644 libsrc/telemon24/crt0.s create mode 100644 libsrc/telemon24/ctype.s create mode 100644 libsrc/telemon24/hires.s create mode 100644 libsrc/telemon24/mainargs.s create mode 100644 libsrc/telemon24/oserrlist.s create mode 100644 libsrc/telemon24/oserror.s create mode 100644 libsrc/telemon24/print.s create mode 100644 libsrc/telemon24/sysuname.s create mode 100644 libsrc/telemon24/tapehdr.s create mode 100644 libsrc/telemon24/write.s diff --git a/doc/telemon24.sgml b/doc/telemon24.sgml new file mode 100644 index 000000000..b4e1befa1 --- /dev/null +++ b/doc/telemon24.sgml @@ -0,0 +1,42 @@ + + +
+ +Oric Telemon 2.4 -specific information for cc65 +<author> + +<url url="mailto:greg.king5@verizon.net" name="Greg King"> +<date>2017-01-22 + +<abstract> +An overview over the Telemon 3.0 runtime system as it is implemented for the cc65 C +compiler. +</abstract> + +<!-- Table of contents --> +<toc> + + + +<sect>License<p> + +This software is provided 'as-is', without any expressed or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + +<enum> +<item> The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. +<item> Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. +<item> This notice may not be removed or altered from any source + distribution. +</enum> + +</article> diff --git a/doc/telemon30.sgml b/doc/telemon30.sgml new file mode 100644 index 000000000..ce9e044b4 --- /dev/null +++ b/doc/telemon30.sgml @@ -0,0 +1,177 @@ +<!doctype linuxdoc system> + +<article> + +<title>Oric Telestrat-specific information for cc65 +<author> +<url url="mailto:jede@oric.org" name="Jede">,<newline> + +<date>2017-01-22 + +<abstract> +An overview over the Telestrat (telemon 3.0 : http://orix.oric.org) runtime system as it is implemented for the cc65 C +compiler. +</abstract> + +<!-- Table of contents --> +<toc> + +<!-- Begin the document --> + +<sect>Overview<p> + +This file contains an overview of the Telestrat runtime system as it comes with the +cc65 C compiler. It describes the memory layout, Telemon3.0-specific header files, +available drivers, and any pitfalls specific to that platform. + +Please note that Telemon3.0-specific functions are just mentioned here, they are +described in detail in the separate <url url="funcref.html" name="function +reference">. Even functions marked as "platform dependent" may be available on +more than one platform. Please see the function reference for more +information. + + + +<sect>Binary format<p> + +The standard binary output format generated by the linker for the Telemon 3.0 target +is a machine language program with a 20 bytes header described here : http://orix.oric.org/doku.php?id=orix:header + + + +<sect>Memory layout<p> + +In the standard setup, cc65-generated programs use the memory from +$0801 to $9800; so, nearly 37K of memory (including the stack) is +available. ROM calls are possible without further precautions. + + + +Special locations: + +<descrip> + <tag/Stack/ + The C runtime stack is located at $97FF (or $B3FF), and grows + downwards. + + <tag/Heap/ + The C heap is located at the end of the program, and grows towards the C + runtime stack. + +</descrip><p> + + + +<sect>Platform-specific header files<p> + +Programs containing Telemon 3.0 -specific code may use the <tt/telemon.h/ header file. + + +<sect1>Telemon 3.0-specific functions<p> + +The functions listed below are special for the Telemon 3.0. See the <url +url="funcref.html" name="function reference"> for declaration and usage. + +<itemize> +<item>explode +<item>ping +<item>shoot +<item>zap +<item>oupsx +</itemize> + + +<sect1>Hardware access<p> + +The following pseudo variables declared in the <tt/atmos.h/ header file do allow +access to hardware located in the address space. Some variables are +structures; accessing the struct fields will access the chip registers. + +<descrip> + + <tag><tt/VIA/</tag> + Access to the VIA (Versatile Interface Adapter) chip is available via the + <tt/VIA/ variable. The structure behind this variable is explained in <tt/_6522.h/. + +</descrip><p> + + + +<sect>Loadable drivers<p> + +<em>Note:</em> Since the Atmos doesn't have working disk I/O +(see <ref id="limitations" name="section "Limitations"">), the +available drivers cannot be loaded at runtime (so the term "loadable drivers" +is somewhat misleading). Instead, the drivers have to be statically linked. While +this may seem overhead, it has two advantages: + + +<sect1>Extended memory drivers<p> + +No extended memory drivers are currently available for the Atmos. + + +<sect1>Joystick drivers<p> + +<descrip> + +telemon 3.0 manages joysticks but it had been handled yet. + +</descrip><p> + + +<sect1>Mouse drivers<p> + +Telemon 3.0 manages also mouse, but it had been no handled yet in this version. + +<sect1>RS232 device drivers<p> + +<descrip> + +not done + +</descrip><p> + + + +<sect>Limitations<label id="limitations"><p> + +<sect1>Disk I/O<p> + +This version handles fopen, fread, fclose primitives. Because Telemon 3.0 handles these two primitives. By the way, +it uses an extension "ch376 card" which handles sdcard and FAT 32 usb key. + +<itemize> +<item>fclose +<item>fopen +<item>fread + +</itemize> + + + +<sect>Other hints<p> + + +<sect>License<p> + +This software is provided 'as-is', without any expressed or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + +<enum> +<item> The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. +<item> Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. +<item> This notice may not be removed or altered from any source + distribution. +</enum> + +</article> diff --git a/libsrc/telemon24/_scrsize.s b/libsrc/telemon24/_scrsize.s new file mode 100644 index 000000000..305e41c46 --- /dev/null +++ b/libsrc/telemon24/_scrsize.s @@ -0,0 +1,19 @@ +; +; 2003-04-13, Ullrich von Bassewitz +; 2013-07-16, Greg King +; +; Screen size variables +; + + .export screensize + .include "telemon24.inc" + +.proc screensize + + ldx #SCREEN_XSIZE + ldy #SCREEN_YSIZE + rts + +.endproc + + diff --git a/libsrc/telemon24/crt0.s b/libsrc/telemon24/crt0.s new file mode 100644 index 000000000..a3c92a360 --- /dev/null +++ b/libsrc/telemon24/crt0.s @@ -0,0 +1,101 @@ +; +; Startup code for cc65 (Oric version) +; +; By Debrune Jérôme <jede@oric.org> and Ullrich von Bassewitz <uz@cc65.org> +; 2016-03-18, Greg King +; + + .export _exit + .export __STARTUP__ : absolute = 1 ; Mark as startup + + .import initlib, donelib + .import callmain, zerobss + .import __MAIN_START__, __MAIN_SIZE__ + + .include "zeropage.inc" + .include "telemon24.inc" + +; ------------------------------------------------------------------------ +; Place the startup code in a special segment. + +.segment "STARTUP" + + tsx + stx spsave ; Save system stk ptr + +; Save space by putting some of the start-up code in a segment +; that will be re-used. + + jsr init + +; Clear the BSS variables (after the constructors have been run). + + jsr zerobss + +; Push the command-line arguments; and, call main(). + + jsr callmain + +; Call the module destructors. This is also the exit() entry. + +_exit: jsr donelib + +; Restore the system stuff. + + ldx spsave + txs +; lda stsave + ; sta STATUS + +; Copy back the zero-page stuff. + + ldx #zpspace - 1 +L2: lda zpsave,x + sta sp,x + dex + bpl L2 + +; Back to BASIC. + + rts + +; ------------------------------------------------------------------------ +; Put this code in a place that will be re-used by BSS, the heap, +; and the C stack. + +.segment "ONCE" + +; Save the zero-page area that we're about to use. + +init: ldx #zpspace - 1 +L1: lda sp,x + sta zpsave,x + dex + bpl L1 + +; Currently, color isn't supported on the text screen. +; Unprotect screen columns 0 and 1 (where each line's color codes would sit). + + ; lda STATUS + ; sta stsave + ; and #%11011111 + ; sta STATUS + +; Set up the C stack. + + lda #<(__MAIN_START__ + __MAIN_SIZE__) + ldx #>(__MAIN_START__ + __MAIN_SIZE__) + sta sp + stx sp+1 ; Set argument stack ptr + +; Call the module constructors. + + jmp initlib + +; ------------------------------------------------------------------------ + +.segment "INIT" + +spsave: .res 1 +stsave: .res 1 +zpsave: .res zpspace diff --git a/libsrc/telemon24/ctype.s b/libsrc/telemon24/ctype.s new file mode 100644 index 000000000..79edafbb2 --- /dev/null +++ b/libsrc/telemon24/ctype.s @@ -0,0 +1,299 @@ +; +; Ullrich von Bassewitz, 2003-04-13 +; +; Character specification table. +; + +; The tables are readonly, put them into the rodata segment + +.rodata + +; The following 256 byte wide table specifies attributes for the isxxx type +; of functions. Doing it by a table means some overhead in space, but it +; has major advantages: +; +; * It is fast. If it were'nt for the slow parameter passing of cc65, one +; could even define macros for the isxxx functions (this is usually +; done on other platforms). +; +; * It is highly portable. The only unportable part is the table itself, +; all real code goes into the common library. +; +; * We save some code in the isxxx functions. +; +; +; Bit assignments: +; +; 0 - Lower case char +; 1 - Upper case char +; 2 - Numeric digit +; 3 - Hex digit (both, lower and upper) +; 4 - Control character +; 5 - The space character itself +; 6 - Other whitespace (that is: '\f', '\n', '\r', '\t' and '\v') +; 7 - Space or tab character + + .export __ctype + +__ctype: + .byte $10 ; 0/00 ___ctrl_@___ + .byte $10 ; 1/01 ___ctrl_A___ + .byte $10 ; 2/02 ___ctrl_B___ + .byte $10 ; 3/03 ___ctrl_C___ + .byte $10 ; 4/04 ___ctrl_D___ + .byte $10 ; 5/05 ___ctrl_E___ + .byte $10 ; 6/06 ___ctrl_F___ + .byte $10 ; 7/07 ___ctrl_G___ + .byte $10 ; 8/08 ___ctrl_H___ + .byte $D0 ; 9/09 ___ctrl_I___ + .byte $50 ; 10/0a ___ctrl_J___ + .byte $50 ; 11/0b ___ctrl_K___ + .byte $50 ; 12/0c ___ctrl_L___ + .byte $50 ; 13/0d ___ctrl_M___ + .byte $10 ; 14/0e ___ctrl_N___ + .byte $10 ; 15/0f ___ctrl_O___ + .byte $10 ; 16/10 ___ctrl_P___ + .byte $10 ; 17/11 ___ctrl_Q___ + .byte $10 ; 18/12 ___ctrl_R___ + .byte $10 ; 19/13 ___ctrl_S___ + .byte $10 ; 20/14 ___ctrl_T___ + .byte $10 ; 21/15 ___ctrl_U___ + .byte $10 ; 22/16 ___ctrl_V___ + .byte $10 ; 23/17 ___ctrl_W___ + .byte $10 ; 24/18 ___ctrl_X___ + .byte $10 ; 25/19 ___ctrl_Y___ + .byte $10 ; 26/1a ___ctrl_Z___ + .byte $10 ; 27/1b ___ctrl_[___ + .byte $10 ; 28/1c ___ctrl_\___ + .byte $10 ; 29/1d ___ctrl_]___ + .byte $10 ; 30/1e ___ctrl_^___ + .byte $10 ; 31/1f ___ctrl_____ + .byte $A0 ; 32/20 ___SPACE___ + .byte $00 ; 33/21 _____!_____ + .byte $00 ; 34/22 _____"_____ + .byte $00 ; 35/23 _____#_____ + .byte $00 ; 36/24 _____$_____ + .byte $00 ; 37/25 _____%_____ + .byte $00 ; 38/26 _____&_____ + .byte $00 ; 39/27 _____'_____ + .byte $00 ; 40/28 _____(_____ + .byte $00 ; 41/29 _____)_____ + .byte $00 ; 42/2a _____*_____ + .byte $00 ; 43/2b _____+_____ + .byte $00 ; 44/2c _____,_____ + .byte $00 ; 45/2d _____-_____ + .byte $00 ; 46/2e _____._____ + .byte $00 ; 47/2f _____/_____ + .byte $0C ; 48/30 _____0_____ + .byte $0C ; 49/31 _____1_____ + .byte $0C ; 50/32 _____2_____ + .byte $0C ; 51/33 _____3_____ + .byte $0C ; 52/34 _____4_____ + .byte $0C ; 53/35 _____5_____ + .byte $0C ; 54/36 _____6_____ + .byte $0C ; 55/37 _____7_____ + .byte $0C ; 56/38 _____8_____ + .byte $0C ; 57/39 _____9_____ + .byte $00 ; 58/3a _____:_____ + .byte $00 ; 59/3b _____;_____ + .byte $00 ; 60/3c _____<_____ + .byte $00 ; 61/3d _____=_____ + .byte $00 ; 62/3e _____>_____ + .byte $00 ; 63/3f _____?_____ + + .byte $00 ; 64/40 _____@_____ + .byte $0A ; 65/41 _____A_____ + .byte $0A ; 66/42 _____B_____ + .byte $0A ; 67/43 _____C_____ + .byte $0A ; 68/44 _____D_____ + .byte $0A ; 69/45 _____E_____ + .byte $0A ; 70/46 _____F_____ + .byte $02 ; 71/47 _____G_____ + .byte $02 ; 72/48 _____H_____ + .byte $02 ; 73/49 _____I_____ + .byte $02 ; 74/4a _____J_____ + .byte $02 ; 75/4b _____K_____ + .byte $02 ; 76/4c _____L_____ + .byte $02 ; 77/4d _____M_____ + .byte $02 ; 78/4e _____N_____ + .byte $02 ; 79/4f _____O_____ + .byte $02 ; 80/50 _____P_____ + .byte $02 ; 81/51 _____Q_____ + .byte $02 ; 82/52 _____R_____ + .byte $02 ; 83/53 _____S_____ + .byte $02 ; 84/54 _____T_____ + .byte $02 ; 85/55 _____U_____ + .byte $02 ; 86/56 _____V_____ + .byte $02 ; 87/57 _____W_____ + .byte $02 ; 88/58 _____X_____ + .byte $02 ; 89/59 _____Y_____ + .byte $02 ; 90/5a _____Z_____ + .byte $00 ; 91/5b _____[_____ + .byte $00 ; 92/5c _____\_____ + .byte $00 ; 93/5d _____]_____ + .byte $00 ; 94/5e _____^_____ + .byte $00 ; 95/5f _UNDERLINE_ + .byte $00 ; 96/60 ___grave___ + .byte $09 ; 97/61 _____a_____ + .byte $09 ; 98/62 _____b_____ + .byte $09 ; 99/63 _____c_____ + .byte $09 ; 100/64 _____d_____ + .byte $09 ; 101/65 _____e_____ + .byte $09 ; 102/66 _____f_____ + .byte $01 ; 103/67 _____g_____ + .byte $01 ; 104/68 _____h_____ + .byte $01 ; 105/69 _____i_____ + .byte $01 ; 106/6a _____j_____ + .byte $01 ; 107/6b _____k_____ + .byte $01 ; 108/6c _____l_____ + .byte $01 ; 109/6d _____m_____ + .byte $01 ; 110/6e _____n_____ + .byte $01 ; 111/6f _____o_____ + .byte $01 ; 112/70 _____p_____ + .byte $01 ; 113/71 _____q_____ + .byte $01 ; 114/72 _____r_____ + .byte $01 ; 115/73 _____s_____ + .byte $01 ; 116/74 _____t_____ + .byte $01 ; 117/75 _____u_____ + .byte $01 ; 118/76 _____v_____ + .byte $01 ; 119/77 _____w_____ + .byte $01 ; 120/78 _____x_____ + .byte $01 ; 121/79 _____y_____ + .byte $01 ; 122/7a _____z_____ + .byte $00 ; 123/7b _____{_____ + .byte $00 ; 124/7c _____|_____ + .byte $00 ; 125/7d _____}_____ + .byte $00 ; 126/7e _____~_____ + .byte $40 ; 127/7f ____DEL____ + + .byte $00 ; 128/80 ___________ + .byte $00 ; 129/81 ___________ + .byte $00 ; 130/82 ___________ + .byte $00 ; 131/83 ___________ + .byte $00 ; 132/84 ___________ + .byte $00 ; 133/85 ___________ + .byte $00 ; 134/86 ___________ + .byte $00 ; 135/87 ___________ + .byte $00 ; 136/88 ___________ + .byte $00 ; 137/89 ___________ + .byte $00 ; 138/8a ___________ + .byte $00 ; 139/8b ___________ + .byte $00 ; 140/8c ___________ + .byte $00 ; 141/8d ___________ + .byte $00 ; 142/8e ___________ + .byte $00 ; 143/8f ___________ + .byte $00 ; 144/90 ___________ + .byte $00 ; 145/91 ___________ + .byte $00 ; 146/92 ___________ + .byte $10 ; 147/93 ___________ + .byte $00 ; 148/94 ___________ + .byte $00 ; 149/95 ___________ + .byte $00 ; 150/96 ___________ + .byte $00 ; 151/97 ___________ + .byte $00 ; 152/98 ___________ + .byte $00 ; 153/99 ___________ + .byte $00 ; 154/9a ___________ + .byte $00 ; 155/9b ___________ + .byte $00 ; 156/9c ___________ + .byte $00 ; 157/9d ___________ + .byte $00 ; 158/9e ___________ + .byte $00 ; 159/9f ___________ + + .byte $00 ; 160/a0 ___________ + .byte $00 ; 161/a1 ___________ + .byte $00 ; 162/a2 ___________ + .byte $00 ; 163/a3 ___________ + .byte $00 ; 164/a4 ___________ + .byte $00 ; 165/a5 ___________ + .byte $00 ; 166/a6 ___________ + .byte $00 ; 167/a7 ___________ + .byte $00 ; 168/a8 ___________ + .byte $00 ; 169/a9 ___________ + .byte $00 ; 170/aa ___________ + .byte $00 ; 171/ab ___________ + .byte $00 ; 172/ac ___________ + .byte $00 ; 173/ad ___________ + .byte $00 ; 174/ae ___________ + .byte $00 ; 175/af ___________ + .byte $00 ; 176/b0 ___________ + .byte $00 ; 177/b1 ___________ + .byte $00 ; 178/b2 ___________ + .byte $00 ; 179/b3 ___________ + .byte $00 ; 180/b4 ___________ + .byte $00 ; 181/b5 ___________ + .byte $00 ; 182/b6 ___________ + .byte $00 ; 183/b7 ___________ + .byte $00 ; 184/b8 ___________ + .byte $00 ; 185/b9 ___________ + .byte $00 ; 186/ba ___________ + .byte $00 ; 187/bb ___________ + .byte $00 ; 188/bc ___________ + .byte $00 ; 189/bd ___________ + .byte $00 ; 190/be ___________ + .byte $00 ; 191/bf ___________ + + .byte $02 ; 192/c0 ___________ + .byte $02 ; 193/c1 ___________ + .byte $02 ; 194/c2 ___________ + .byte $02 ; 195/c3 ___________ + .byte $02 ; 196/c4 ___________ + .byte $02 ; 197/c5 ___________ + .byte $02 ; 198/c6 ___________ + .byte $02 ; 199/c7 ___________ + .byte $02 ; 200/c8 ___________ + .byte $02 ; 201/c9 ___________ + .byte $02 ; 202/ca ___________ + .byte $02 ; 203/cb ___________ + .byte $02 ; 204/cc ___________ + .byte $02 ; 205/cd ___________ + .byte $02 ; 206/ce ___________ + .byte $02 ; 207/cf ___________ + .byte $02 ; 208/d0 ___________ + .byte $02 ; 209/d1 ___________ + .byte $02 ; 210/d2 ___________ + .byte $02 ; 211/d3 ___________ + .byte $02 ; 212/d4 ___________ + .byte $02 ; 213/d5 ___________ + .byte $02 ; 214/d6 ___________ + .byte $02 ; 215/d7 ___________ + .byte $02 ; 216/d8 ___________ + .byte $02 ; 217/d9 ___________ + .byte $02 ; 218/da ___________ + .byte $02 ; 219/db ___________ + .byte $02 ; 220/dc ___________ + .byte $02 ; 221/dd ___________ + .byte $02 ; 222/de ___________ + .byte $00 ; 223/df ___________ + .byte $01 ; 224/e0 ___________ + .byte $01 ; 225/e1 ___________ + .byte $01 ; 226/e2 ___________ + .byte $01 ; 227/e3 ___________ + .byte $01 ; 228/e4 ___________ + .byte $01 ; 229/e5 ___________ + .byte $01 ; 230/e6 ___________ + .byte $01 ; 231/e7 ___________ + .byte $01 ; 232/e8 ___________ + .byte $01 ; 233/e9 ___________ + .byte $01 ; 234/ea ___________ + .byte $01 ; 235/eb ___________ + .byte $01 ; 236/ec ___________ + .byte $01 ; 237/ed ___________ + .byte $01 ; 238/ee ___________ + .byte $01 ; 239/ef ___________ + .byte $01 ; 240/f0 ___________ + .byte $01 ; 241/f1 ___________ + .byte $01 ; 242/f2 ___________ + .byte $01 ; 243/f3 ___________ + .byte $01 ; 244/f4 ___________ + .byte $01 ; 245/f5 ___________ + .byte $01 ; 246/f6 ___________ + .byte $01 ; 247/f7 ___________ + .byte $01 ; 248/f8 ___________ + .byte $01 ; 249/f9 ___________ + .byte $01 ; 250/fa ___________ + .byte $01 ; 251/fb ___________ + .byte $01 ; 252/fc ___________ + .byte $01 ; 253/fd ___________ + .byte $01 ; 254/fe ___________ + .byte $00 ; 255/ff ___________ + diff --git a/libsrc/telemon24/hires.s b/libsrc/telemon24/hires.s new file mode 100644 index 000000000..80d67824c --- /dev/null +++ b/libsrc/telemon24/hires.s @@ -0,0 +1,22 @@ +; +; Ullrich von Bassewitz, 2003-04-13 +; +; void hires(void); +; +; This function is a hack! +; + + .export _hires + + + .include "telemon24.inc" + + +; can be optimized with a macro +.proc _hires + brk + .byt $1a + rts +.endproc + + diff --git a/libsrc/telemon24/mainargs.s b/libsrc/telemon24/mainargs.s new file mode 100644 index 000000000..d8547e500 --- /dev/null +++ b/libsrc/telemon24/mainargs.s @@ -0,0 +1,36 @@ +; +; 2003-03-07, Ullrich von Bassewitz +; 2011-01-28, Stefan Haubenthal +; 2014-09-10, Greg King +; +; Set up arguments for main +; + + .constructor initmainargs, 24 + .import __argc, __argv + + .include "telemon24.inc" + .macpack generic + +MAXARGS = 10 ; Maximum number of arguments allowed + + +.segment "ONCE" + +.proc initmainargs + +.endproc + +.segment "INIT" + +term: .res 1 +name: .res FNAME_LEN + 1 +args: .res SCREEN_XSIZE * 2 - 1 + +.data + +; This array has zeroes when initmainargs starts. +; char* argv[MAXARGS+1]={name}; + +argv: .addr name + .res MAXARGS * 2 diff --git a/libsrc/telemon24/oserrlist.s b/libsrc/telemon24/oserrlist.s new file mode 100644 index 000000000..8ec41de6d --- /dev/null +++ b/libsrc/telemon24/oserrlist.s @@ -0,0 +1,75 @@ +; +; Stefan Haubenthal, 2004-05-25 +; Ullrich von Bassewitz, 18.07.2002 +; +; Defines the platform specific error list. +; +; The table is built as a list of entries +; +; .byte entrylen +; .byte errorcode +; .asciiz errormsg +; +; and terminated by an entry with length zero that is returned if the +; error code could not be found. +; + + .export __sys_oserrlist + +;---------------------------------------------------------------------------- +; Macros used to generate the list (may get moved to an include file?) + +; Regular entry +.macro sys_oserr_entry code, msg + .local Start, End +Start: .byte End - Start + .byte code + .asciiz msg +End: +.endmacro + +; Sentinel entry +.macro sys_oserr_sentinel msg + .byte 0 ; Length is always zero + .byte 0 ; Code is unused + .asciiz msg +.endmacro + +;---------------------------------------------------------------------------- +; The error message table + +.rodata + +__sys_oserrlist: + sys_oserr_entry 1, "File not found" + sys_oserr_entry 2, "Invalid command end" + sys_oserr_entry 3, "No drive number" + sys_oserr_entry 4, "Bad drive number" + sys_oserr_entry 5, "Invalid filename" + sys_oserr_entry 6, "fderr=(error number)" + sys_oserr_entry 7, "Illegal attribute" + sys_oserr_entry 8, "Wildcard(s) not allowed" + sys_oserr_entry 9, "File already exists" + sys_oserr_entry 10, "Insufficient disc space" + sys_oserr_entry 11, "File open" + sys_oserr_entry 12, "Illegal quantity" + sys_oserr_entry 13, "End address missing" + sys_oserr_entry 14, "Start address > end address" + sys_oserr_entry 15, "Missing 'to'" + sys_oserr_entry 16, "Renamed file not on same disc" + sys_oserr_entry 17, "Unknown array" + sys_oserr_entry 18, "Target drive not source drive" + sys_oserr_entry 19, "Destination not specified" + sys_oserr_entry 20, "Cannot merge and overwrite" + sys_oserr_entry 21, "Single target file illegal" + sys_oserr_entry 22, "Syntax" + sys_oserr_entry 23, "Filename missing" + sys_oserr_entry 24, "Source file missing" + sys_oserr_entry 25, "Type mismatch" + sys_oserr_entry 26, "Disc write-protected" + sys_oserr_entry 27, "Incompatible drives" + sys_oserr_entry 28, "File not open" + sys_oserr_entry 29, "File end" + sys_oserr_sentinel "Unknown error" + + diff --git a/libsrc/telemon24/oserror.s b/libsrc/telemon24/oserror.s new file mode 100644 index 000000000..37c9bd7fc --- /dev/null +++ b/libsrc/telemon24/oserror.s @@ -0,0 +1,17 @@ +; +; Stefan Haubenthal, 2011-04-18 +; +; int __fastcall__ _osmaperrno (unsigned char oserror); +; /* Map a system specific error into a system independent code */ +; + + .include "errno.inc" + .export __osmaperrno + +.proc __osmaperrno + + lda #<EUNKNOWN + ldx #>EUNKNOWN + rts + +.endproc diff --git a/libsrc/telemon24/print.s b/libsrc/telemon24/print.s new file mode 100644 index 000000000..a135cdd18 --- /dev/null +++ b/libsrc/telemon24/print.s @@ -0,0 +1,25 @@ +; +; Jede +; +; print (char * str); +; +; This function is a hack! +; + + .export _print + .import popax + .importzp tmp1 + .include "telemon24.inc" + +.proc _print + + jsr popax ; get buf + stx tmp1 + ldy tmp1 + brk + .byte $14 + rts + +.endproc + + diff --git a/libsrc/telemon24/sysuname.s b/libsrc/telemon24/sysuname.s new file mode 100644 index 000000000..51af1d8fe --- /dev/null +++ b/libsrc/telemon24/sysuname.s @@ -0,0 +1,46 @@ +; +; Ullrich von Bassewitz, 2003-08-12 +; +; unsigned char __fastcall__ _sysuname (struct utsname* buf); +; + + .export __sysuname, utsdata + + .import utscopy + + __sysuname = utscopy + +;-------------------------------------------------------------------------- +; Data. We define a fixed utsname struct here and just copy it. + +.rodata + +utsdata: + ; sysname + .asciiz "cc65" + + ; nodename + .asciiz "" + + ; release + .byte ((.VERSION >> 8) & $0F) + '0' + .byte '.' + .if ((.VERSION >> 4) & $0F) > 9 + .byte ((.VERSION >> 4) & $0F) / 10 + '0' + .byte ((.VERSION >> 4) & $0F) .MOD 10 + '0' + .else + .byte ((.VERSION >> 4) & $0F) + '0' + .endif + .byte $00 + + ; version + .if (.VERSION & $0F) > 9 + .byte (.VERSION & $0F) / 10 + '0' + .byte (.VERSION & $0F) .MOD 10 + '0' + .else + .byte (.VERSION & $0F) + '0' + .endif + .byte $00 + + ; machine + .asciiz "Oric Telestrat" diff --git a/libsrc/telemon24/tapehdr.s b/libsrc/telemon24/tapehdr.s new file mode 100644 index 000000000..9b183e11e --- /dev/null +++ b/libsrc/telemon24/tapehdr.s @@ -0,0 +1,36 @@ +; +; Based on code by Debrune Jérôme <jede@oric.org> +; 2016-03-17, Greg King +; + + ; The following symbol is used by the linker config. file + ; to force this module to be included into the output file. + .export __ORIXHDR__:abs = 1 + + ; These symbols, also, come from the configuration file. + .import __AUTORUN__, __PROGFLAG__ + .import __BASHEAD_START__, __MAIN_LAST__ + + +; ------------------------------------------------------------------------ +; Oric cassette-tape header + +.segment "ORIXHDR" + + .byte $01, $00 ; + + .byte "ORI" + + .byte $01 ; version + .byte $00,$00 ; mode + .byte $00,$00 ; cpu type + .byte $00,$00 ; OS + + .byte $00 ; reserved + .byte $00 ; auto + + + .dbyt __BASHEAD_START__ ; Address of start of file + .dbyt __MAIN_LAST__ - 1 ; Address of end of file + .dbyt __BASHEAD_START__ ; Address of start of file + diff --git a/libsrc/telemon24/write.s b/libsrc/telemon24/write.s new file mode 100644 index 000000000..32bbf617c --- /dev/null +++ b/libsrc/telemon24/write.s @@ -0,0 +1,59 @@ +; +; Ullrich von Bassewitz, 2003-04-13 +; +; int write (int fd, const void* buf, int count); +; +; This function is a hack! +; + + .export _write + .import popax + .importzp ptr1, ptr2, ptr3, tmp1 + + .include "telemon24.inc" + +.proc _write + + sta ptr3 + stx ptr3+1 ; save count as result + + eor #$FF + sta ptr2 + txa + eor #$FF + sta ptr2+1 ; Remember -count-1 + + jsr popax ; get buf + sta ptr1 + stx ptr1+1 + jsr popax ; get fd and discard +L1: inc ptr2 + bne L2 + inc ptr2+1 + beq L9 +L2: ldy #0 + lda (ptr1),y + tax + cpx #$0A ; Check for \n + bne L3 + brk + .byt $10 + + ldx #$0D +L3: + brk + .byt $10 + inc ptr1 + bne L1 + inc ptr1+1 + jmp L1 + +; No error, return count + +L9: lda ptr3 + ldx ptr3+1 + rts + +.endproc + + From d1b5a6632d558c0ffb9b89f1cbf239ae04533b90 Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Sun, 29 Jan 2017 21:18:49 +0100 Subject: [PATCH 05/29] Adding telemon30 and telemon24 primitives --- asminc/telemon24.inc | 68 ++++++++ asminc/telemon30.inc | 150 ++++++++++++++++++ cfg/telemon24.cfg | 43 +++++ include/telemon30.h | 21 +++ libsrc/telemon30/_close.s | 17 ++ libsrc/telemon30/_open.s | 60 ++----- libsrc/telemon30/_read.s | 46 ++++-- libsrc/telemon30/ch376.s | 307 +++++++++++++++++++++++++++--------- libsrc/telemon30/graphics.s | 13 +- libsrc/telemon30/orixhdr.s | 15 +- libsrc/telemon30/write.s | 22 +++ 11 files changed, 616 insertions(+), 146 deletions(-) create mode 100644 asminc/telemon24.inc create mode 100644 asminc/telemon30.inc create mode 100644 cfg/telemon24.cfg create mode 100644 include/telemon30.h create mode 100644 libsrc/telemon30/_close.s diff --git a/asminc/telemon24.inc b/asminc/telemon24.inc new file mode 100644 index 000000000..0b58d63a6 --- /dev/null +++ b/asminc/telemon24.inc @@ -0,0 +1,68 @@ +; +; Oric Telemon definition +; Telemon 2.4 +; + + +; --------------------------------------------------------------------------- +; Constants + +SCREEN_XSIZE = 40 ; screen columns +SCREEN_YSIZE = 28 ; screen rows + +FUNCTKEY = $A5 + +FNAME_LEN = 11 ; maximum length of file-name + + +; --------------------------------------------------------------------------- +; Zero page + + + + +; --------------------------------------------------------------------------- +; Low memory + + + + +; --------------------------------------------------------------------------- +; I/O locations + +; 6522 +.struct VIA ; Versatile Interface Adapter + .res $0300 +PRB .byte ; Port Register B +PRA .byte ; Port Register A +DDRB .byte ; Data Direction Register B +DDRA .byte ; Data Direction Register A +T1 .word ; Timer 1 +T1L .word ; Timer 1 Latch +T2 .word ; Timer 2 +SR .byte ; Shift Register +ACR .byte ; Auxiliary Control Register +PCR .byte ; Peripheral Control Register +IFR .byte ; Interrupt Flags Register +IER .byte ; Interrupt Enable Register +PRA2 .byte ; Port Register A without handshaking +.endstruct + +; 6551 +.struct ACIA ; Asynchronous Communications Interface Adapter + .res $031C +DATA .byte +STATUS .byte +CMD .byte ; Command register +CTRL .byte ; Control register +.endstruct + +SCREEN := $BB80 + + +; --------------------------------------------------------------------------- +; ROM entries + +XWR0 := $10 +XWSTR0 := $14 + diff --git a/asminc/telemon30.inc b/asminc/telemon30.inc new file mode 100644 index 000000000..acfd7e919 --- /dev/null +++ b/asminc/telemon30.inc @@ -0,0 +1,150 @@ +; +; Oric Telemon definition +; Telemon 2.4 +; + + +; --------------------------------------------------------------------------- +; Constants + +SCREEN_XSIZE = 40 ; screen columns +SCREEN_YSIZE = 28 ; screen rows + +FUNCTKEY = $A5 + +FNAME_LEN = 11 ; maximum length of file-name + + +; --------------------------------------------------------------------------- +; Zero page + + + + +; --------------------------------------------------------------------------- +; Low memory + + + + +; --------------------------------------------------------------------------- +; I/O locations + +; 6522 +.struct VIA ; Versatile Interface Adapter + .res $0300 +PRB .byte ; Port Register B +PRA .byte ; Port Register A +DDRB .byte ; Data Direction Register B +DDRA .byte ; Data Direction Register A +T1 .word ; Timer 1 +T1L .word ; Timer 1 Latch +T2 .word ; Timer 2 +SR .byte ; Shift Register +ACR .byte ; Auxiliary Control Register +PCR .byte ; Peripheral Control Register +IFR .byte ; Interrupt Flags Register +IER .byte ; Interrupt Enable Register +PRA2 .byte ; Port Register A without handshaking +.endstruct + + +.struct VIA2 ; Versatile Interface Adapter + .res $0320 +PRB .byte ; Port Register B +PRA .byte ; Port Register A +DDRB .byte ; Data Direction Register B +DDRA .byte ; Data Direction Register A +T1 .word ; Timer 1 +T1L .word ; Timer 1 Latch +T2 .word ; Timer 2 +SR .byte ; Shift Register +ACR .byte ; Auxiliary Control Register +PCR .byte ; Peripheral Control Register +IFR .byte ; Interrupt Flags Register +IER .byte ; Interrupt Enable Register +PRA2 .byte ; Port Register A without handshaking +.endstruct + +; 6551 +.struct ACIA ; Asynchronous Communications Interface Adapter + .res $031C +DATA .byte +STATUS .byte +CMD .byte ; Command register +CTRL .byte ; Control register +.endstruct + +SCREEN := $BB80 + + +; --------------------------------------------------------------------------- +; ROM entries + +; primitives telemon 2.4 +XRD0 := $08 +XRDW0 := $0c +XWR0 := $10 +XWSTR0 := $14 +XTEXT := $19 +XHIRES := $1A +XMINMA := $1f +XFREAD := $27 ; only in TELEMON 3.0 +XOPEN := $30 ; only in TELEMON 3.0 +XCOSCR := $34 ; switch off cursor +XCSSCR := $35 ; switch on cursor +XCLOSE := $3a ; Close file +XFWRITE:= $3b ; write + +XSONPS := $40 +XOUPS := $42 +XPLAY := $43 +XSOUND := $44 +XMUSIC := $45 +XZAP := $46 +XSHOOT := $47 +XCIRCL := $8f +XCURSE := $90 +XEXPLO := $9c +XPING := $9d +XPAPER := $92 +XINK := $93 + + +; --------------------------------------------------------------------------- +; Page 00 +RES := $00 +RESB := $02 + +TR0 := $0c +TR1 := $0d + +PTR_READ_DEST := $2c ; used for XFREAD and XWRITE + +HRSX := $46 +HRSY := $47 + +HRS1 := $4D +HRS2 := $4F +HRS3 := $51 +HRS4 := $53 +HRS5 := $55 + +; --------------------------------------------------------------------------- +; Page $500 + +BUFNOM := $517 +BUFEDT := $590 + +MAX_BUFEDT_LENGTH=110 + +; Hardware +CH376_DATA :=$340 +CH376_COMMAND :=$341 + +; MACRO + + +.macro BRK_TELEMON value + .byte $00,value +.endmacro diff --git a/cfg/telemon24.cfg b/cfg/telemon24.cfg new file mode 100644 index 000000000..b76350868 --- /dev/null +++ b/cfg/telemon24.cfg @@ -0,0 +1,43 @@ +SYMBOLS { + + __ORIXHDR__: type = import; + + __STACKSIZE__: type = weak, value = $0800; # 2K stack + + __RAMEND__: type = weak, value = $9800 + $1C00 ; +} +MEMORY { + ZP: file = "", define = yes, start = $00E2, size = $001A; + ORIXHDR: file = %O, type = ro, start = $0000, size = $001F; + BASHEAD: file = %O, define = yes, start = $0801, size = $000D; + MAIN: file = %O, define = yes, start = __BASHEAD_LAST__, size = __RAMEND__ - __MAIN_START__; + BSS: file = "", start = __ONCE_RUN__, size = __RAMEND__ - __STACKSIZE__ - __ONCE_RUN__; +} +SEGMENTS { + ZEROPAGE: load = ZP, type = zp; + ORIXHDR: load = ORIXHDR, type = ro; + STARTUP: load = MAIN, type = ro; + LOWCODE: load = MAIN, type = ro, optional = yes; + CODE: load = MAIN, type = ro; + RODATA: load = MAIN, type = ro; + DATA: load = MAIN, type = rw; + INIT: load = MAIN, type = rw; + ONCE: load = MAIN, type = ro, define = yes; + BASTAIL: load = MAIN, type = ro, optional = yes; + BSS: load = BSS, type = bss, define = yes; +} +FEATURES { + CONDES: type = constructor, + label = __CONSTRUCTOR_TABLE__, + count = __CONSTRUCTOR_COUNT__, + segment = ONCE; + CONDES: type = destructor, + label = __DESTRUCTOR_TABLE__, + count = __DESTRUCTOR_COUNT__, + segment = RODATA; + CONDES: type = interruptor, + label = __INTERRUPTOR_TABLE__, + count = __INTERRUPTOR_COUNT__, + segment = RODATA, + import = __CALLIRQ__; +} diff --git a/include/telemon30.h b/include/telemon30.h new file mode 100644 index 000000000..73b018444 --- /dev/null +++ b/include/telemon30.h @@ -0,0 +1,21 @@ + +void print (char *); + +void hires(); +void text(); +void oups(); +void ping(); +void zap(); +void shoot(); +void explode(); + +void paper(char color); +void ink(char color); + +void kbdclick1(); + +void curset(char x,char y, char display, char display); +void circle(char rayon); + + + diff --git a/libsrc/telemon30/_close.s b/libsrc/telemon30/_close.s new file mode 100644 index 000000000..84bee3a1b --- /dev/null +++ b/libsrc/telemon30/_close.s @@ -0,0 +1,17 @@ + .export _close + .import addysp,popax + .importzp sp,tmp2,tmp3,tmp1 + + ; int open (const char* name, int flags, ...); /* May take a mode argument */ + .include "telemon30.inc" + .include "errno.inc" + .include "fcntl.inc" + +.proc _close +; Throw away any additional parameters passed through the ellipsis + + BRK_TELEMON XCLOSE ; launch primitive ROM + rts +.endproc + + \ No newline at end of file diff --git a/libsrc/telemon30/_open.s b/libsrc/telemon30/_open.s index a002bbce1..7ea2d8310 100644 --- a/libsrc/telemon30/_open.s +++ b/libsrc/telemon30/_open.s @@ -1,11 +1,12 @@ .export _open .import addysp,popax - .importzp sp,tmp2,tmp3,tmp1 - ; int open (const char* name, int flags, ...); /* May take a mode argument */ - .include "telemon30.inc" - .include "errno.inc" - .include "fcntl.inc" + .importzp sp,tmp2,tmp3,tmp1 + ; int open (const char* name, int flags, ...); /* May take a mode argument */ + .include "telemon30.inc" + .include "errno.inc" + .include "fcntl.inc" + .proc _open ; Throw away any additional parameters passed through the ellipsis @@ -13,53 +14,18 @@ dey ; ...checked (it generates a c compiler warning) dey dey - beq parmok ; Branch if parameter count ok - jsr addysp ; Fix stack, throw away unused parameters + beq parmok ; Branch if parameter count ok + jsr addysp ; Fix stack, throw away unused parameters ; Parameters ok. Pop the flags and save them into tmp3 -parmok: jsr popax ; Get flagss - sta tmp3 ; save flags - - ;AND #O_RDONLY - ;beq READONLY - ;lda tmp3 - ;AND #O_WRONLY - ;beq WRITEONLY - ;jmp next - -;READONLY: -; lda #'r' -; BRK_TELEMON XWR0 -; jmp next -;WRITEONLY: -; lda #'w' -; BRK_TELEMON XWR0 - -;next: +parmok: jsr popax ; Get flagss + sta tmp3 ; save flags ; Get the filename from stack and parse it. Bail out if is not ok - jsr popax ; Get name - - - ldy tmp3 ; Get flags - - - BRK_TELEMON XOPEN - - ; jsr fnparse ; Parse it - ;tax - ;bne oserror ; Bail out if problem with name - -; Get a free file handle and remember it in tmp2 - - ; jsr freefd - ;lda #EMFILE ; Load error code - ;bcs seterrno ; Jump in case of errors - ;stx tmp2 -; - - + jsr popax ; Get name + ldy tmp3 ; Get flags again + BRK_TELEMON XOPEN ; launch primitive ROM rts .endproc diff --git a/libsrc/telemon30/_read.s b/libsrc/telemon30/_read.s index 8f7a20a58..e8bcc3fd0 100644 --- a/libsrc/telemon30/_read.s +++ b/libsrc/telemon30/_read.s @@ -1,29 +1,45 @@ ; -; Ullrich von Bassewitz, 2003-04-13 +; jede jede@oric.org 2017-01-22 ; -; + .FEATURE c_comments,labels_without_colons,pc_assignment, loose_char_term .export _read .import popax - .importzp ptr1, ptr2, ptr3, tmp1, tmp2 - + + .include "zeropage.inc" .include "telemon30.inc" ; int read (int fd, void* buf, unsigned count); .proc _read - ;jsr popax ; fp pointer don't care - sta tmp1 ; count - stx tmp2 ; count - jsr popax ; get buf - ;lda #$00 - ;ldx #$a0 - sta PTR_READ_DEST - stx PTR_READ_DEST+1 - lda tmp1 ; - ldy tmp2 ; - BRK_TELEMON XFREAD + + sta ptr1 ; count + stx ptr1+1 ; count + jsr popax ; get buf + sta PTR_READ_DEST + stx PTR_READ_DEST+1 + sta ptr2 ; in order to calculate nb of bytes read + stx ptr2+1 ; + + ;jsr popax ; fp pointer don't care in this version + + lda ptr1 ; + ldy ptr1+1 ; + BRK_TELEMON XFREAD ; calls telemon30 routine + ; compute nb of bytes read + lda PTR_READ_DEST+1 + sec + sbc ptr2+1 + tax + lda PTR_READ_DEST + sec + sbc ptr2 + + + + ; Here A and X contains number of bytes read + rts .endproc diff --git a/libsrc/telemon30/ch376.s b/libsrc/telemon30/ch376.s index 24df14471..97245add9 100644 --- a/libsrc/telemon30/ch376.s +++ b/libsrc/telemon30/ch376.s @@ -1,5 +1,5 @@ - ; For XA65 compatibily in the futur + ; For XA65 compatibily in the future .FEATURE c_comments,labels_without_colons,pc_assignment, loose_char_term .export _ch376_set_file_name .export _ch376_file_open @@ -8,14 +8,16 @@ .export _ch376_check_exist .export _ch376_disk_mount .export _ch376_set_usb_mode - .export _ch376_file_create - .export _ch376_fcreate - + + .export _ch376_file_close + .export _ch376_seek_file + .export _ch376_file_create + .export _ch376_fwrite ; High level function - .export _ch376_fcreate + .import popax - .importzp sp,tmp2,tmp3,tmp1 + .include "zeropage.inc" .include "telemon30.inc" /* @@ -24,10 +26,27 @@ CH376_SET_USB_MODE_CODE_USB_HOST_SOF_PACKAGE_AUTOMATICALLY := $06 -CH376_USB_INT_DISK_READ := $1d -CH376_USB_INT_SUCCESS := $14 -CH376_ERR_MISS_FILE := $42 - +CH376_USB_INT_SUCCESS := $14 +CH376_USB_INT_CONNECT := $15 +CH376_USB_INT_DISCONNECT := $16 +CH376_USB_INT_BUF_OVER := $17 +CH376_USB_INT_USB_READY := $18 +CH376_USB_INT_DISK_READ := $1D +CH376_USB_INT_DISK_WRITE := $1E +CH376_USB_INT_DISK_ERR := $1F + + +CH376_ERR_OPEN_DIR := $41 +CH376_ERR_MISS_FILE := $42 +CH376_ERR_FOUND_NAME := $43 +CH376_ERR_DISK_DISCON := $82 +CH376_ERR_LARGE_SECTOR := $84 +CH376_ERR_TYPE_ERROR := $92 +CH376_ERR_BPB_ERROR := $A1 +CH376_ERR_DISK_FULL := $B1 +CH376_ERR_FDT_OVER := $B2 +CH376_ERR_FILE_CLOSE := $B4 + CH376_GET_IC_VER := $01 @@ -36,80 +55,92 @@ CH376_GET_ENTER_SLEEP := $03 CH376_RESET_ALL := $05 CH376_CHECK_EXIST := $06 CH376_GET_FILE_SIZE := $0C + CH376_SET_USB_MODE := $15 CH376_GET_STATUS := $22 CH376_RD_USB_DATA0 := $27 -CH376_SET_FILE_NAME := $2f +CH376_CMD_WR_REQ_DATA := $2d +CH376_SET_FILE_NAME := $2F + CH376_DISK_CONNECT := $30 ; check the disk connection status CH376_DISK_MOUNT := $31 CH376_FILE_OPEN := $32 CH376_FILE_ENUM_GO := $33 CH376_FILE_CREATE := $34 CH376_FILE_CLOSE := $36 +CH376_BYTE_LOCATE := $39 CH376_BYTE_READ := $3A -CH376_BYTE_RD_GO := $3b +CH376_BYTE_RD_GO := $3B CH376_BYTE_WRITE := $3C +CH376_BYTE_WR_GO := $3D CH376_DISK_CAPACITY := $3E CH376_DISK_RD_GO := $55 -.proc _ch376_file_create - lda #CH376_FILE_CREATE - sta CH376_COMMAND - jsr _ch376_wait_response - rts +.proc _ch376_file_close + lda #CH376_FILE_CLOSE + sta CH376_COMMAND + jsr _ch376_wait_response + rts .endproc -; void _ch376_fcreate(char *filename) -.proc _ch376_fcreate - jsr _ch376_set_file_name - jsr _ch376_file_open - jsr _ch376_file_create +.proc _ch376_seek_file + ldx #CH376_BYTE_LOCATE + stx CH376_COMMAND + sta CH376_DATA + sty CH376_DATA + lda #$00 ; Don't manage 32 bits length + sta CH376_DATA + sta CH376_DATA + jsr _ch376_wait_response + rts .endproc ; void ch376_set_file_name(char *filename) .proc _ch376_set_file_name - sta tmp1 - stx tmp1+1 - lda #CH376_SET_FILE_NAME ;$2f - sta CH376_COMMAND - ldy #0 + sta ptr1 + stx ptr1+1 + lda #CH376_SET_FILE_NAME ;$2f + sta CH376_COMMAND + ldy #0 loop: - lda (tmp1),y ; replace by bufnom - beq end ; we reached 0 value - sta CH376_DATA + lda (ptr1),y ; replace by bufnom + beq end ; we reached 0 value + ;BRK_TELEMON XMINMA + sta CH376_DATA iny - cpy #13 ; because we don't manage longfilename shortname =11 - bne loop + cpy #13 ; because we don't manage longfilename shortname =11 + bne loop end: - sta CH376_DATA + sta CH376_DATA rts .endproc -; void _ch376_file_open(); +; char _ch376_file_open(); .proc _ch376_file_open - lda #CH376_FILE_OPEN ; $32 - sta CH376_COMMAND - jsr _ch376_wait_response + lda #CH376_FILE_OPEN ; $32 + sta CH376_COMMAND + jsr _ch376_wait_response +; ldx #0 rts .endproc ;CMD_GET_FILE_SIZE .proc _ch376_get_file_size - lda #CH376_GET_FILE_SIZE - sta CH376_COMMAND - lda #$68 - sta CH376_DATA + lda #CH376_GET_FILE_SIZE + sta CH376_COMMAND + lda #$68 + sta CH376_DATA ; store file leng - lda CH376_DATA - sta tmp1 - lda CH376_DATA - sta tmp1+1 - lda CH376_DATA - sta tmp2 - lda CH376_DATA - sta tmp2+1 + lda CH376_DATA + sta tmp1 + lda CH376_DATA + sta tmp1+1 + lda CH376_DATA + sta tmp2 + lda CH376_DATA + sta tmp2+1 rts .endproc @@ -155,35 +186,35 @@ loop: .proc _ch376_set_usb_mode ; CH376_SET_USB_MODE_CODE_USB_HOST_SOF_PACKAGE_AUTOMATICALLY - pha - lda #CH376_SET_USB_MODE ; $15 - sta CH376_COMMAND - pla - sta CH376_DATA + ldx #CH376_SET_USB_MODE ; $15 + stx CH376_COMMAND + sta CH376_DATA rts .endproc - - + ; void ch376_set_bytes_write(int value); .proc _ch376_set_bytes_write - sta tmp1 - stx tmp1+1 - ldx #CH376_BYTE_WRITE - stx CH376_COMMAND - lda tmp1 - sta CH376_DATA - lda tmp1+1 - sta CH376_DATA - jsr _ch376_wait_response + ldy #CH376_BYTE_WRITE + sty CH376_COMMAND + sta CH376_DATA + stx CH376_DATA + lda #0 + sta CH376_DATA + sta CH376_DATA + jsr _ch376_wait_response rts .endproc .proc _ch376_set_bytes_read - ldx #CH376_BYTE_READ - stx CH376_COMMAND - sta CH376_DATA - sty CH376_DATA - jsr _ch376_wait_response + ldy #CH376_BYTE_READ + sty CH376_COMMAND + ; Storing 32 bits value + sta CH376_DATA + stx CH376_DATA + lda #0 + sta CH376_DATA + sta CH376_DATA + jsr _ch376_wait_response rts .endproc @@ -204,7 +235,7 @@ loop: ; else A contains answer of the controller ldy #$ff loop3: - ldx #$ff ; merci de laisser une valeur importante car parfois en mode non debug, le controleur ne répond pas tout de suite + ldx #$ff ; don't decrease this counter. Because ch376 won't respond if there is a lower value loop: lda CH376_COMMAND and #%10000000 @@ -223,3 +254,137 @@ no_error: rts .endproc +.proc _ch376_fread + ; use ptr1 to count bytes + jsr _ch376_set_bytes_read + +continue: + cmp #CH376_USB_INT_DISK_READ ; something to read + beq we_read + cmp #CH376_USB_INT_SUCCESS ; finished + beq finished + ; TODO in A : $ff X: $ff + lda #0 + tax + rts +we_read: + lda #CH376_RD_USB_DATA0 + sta CH376_COMMAND + + lda CH376_DATA ; contains length read + sta tmp2; Number of bytes to read + + ldy #0 +loop: + lda CH376_DATA ; read the data + sta (PTR_READ_DEST),y + + iny + cpy tmp2 + bne loop + tya + clc + adc PTR_READ_DEST + bcc next + inc PTR_READ_DEST+1 +next: + sta PTR_READ_DEST + + lda #CH376_BYTE_RD_GO + sta CH376_COMMAND + jsr _ch376_wait_response + jmp continue +finished: + ; TODO return bytes read + lda tmp1 + + ldx tmp1+1 + + rts +.endproc + +; void _ch376_fwrite(void *ptr,int number) +.proc _ch376_fwrite + ; use ptr1 to count bytes + sta ptr2 + stx ptr2+1 + + jsr popax + sta PTR_READ_DEST + stx PTR_READ_DEST+1 + + lda ptr2 + ldx ptr2+1 + jsr _ch376_set_bytes_write + ;cmp #CH376_USB_INT_SUCCESS + ;beq finished + ;jsr popax + + ;jsr _ch376_wait_response + +continue: + cmp #CH376_USB_INT_DISK_WRITE ; something to read + beq we_read + cmp #CH376_USB_INT_SUCCESS ; finished + beq finished + ; TODO in A : $ff X: $ff + lda #0 + tax + rts +we_read: + lda #CH376_CMD_WR_REQ_DATA + sta CH376_COMMAND + + lda CH376_DATA ; contains length read + sta tmp2; Number of bytes to read + + + ;ldy #0 +loop: + ;lda (PTR_READ_DEST),y + lda #65 + sta CH376_DATA ; read the data + dec tmp2 + bne loop +; dec ptr2 + ;bne continue3 + ;dec ptr2+1 + ;bne continue3 +;continue3 +; lda ptr2+1 + ;bne continue2 + ;lda ptr2 + ;beq finished +;continue2 +; iny +; cpy tmp2 +; bne loop +; tya +; clc +; adc PTR_READ_DEST +; bcc next +; inc PTR_READ_DEST+1 +;next: +; sta PTR_READ_DEST + + lda #CH376_BYTE_WR_GO + sta CH376_COMMAND + jsr _ch376_wait_response + jmp continue +finished: + ; TODO return bytes read + lda tmp1 + ;lda #<8000 + ldx tmp1+1 + ;ldx #>8000 + rts +.endproc + + + +.proc _ch376_file_create + lda #CH376_FILE_CREATE + sta CH376_COMMAND + jsr _ch376_wait_response + rts +.endproc \ No newline at end of file diff --git a/libsrc/telemon30/graphics.s b/libsrc/telemon30/graphics.s index 1d0beefa5..4f2b09162 100644 --- a/libsrc/telemon30/graphics.s +++ b/libsrc/telemon30/graphics.s @@ -1,7 +1,7 @@ - .export _paper,_hires,_text,_circle,_curset, _switchOffCursor - .importzp sp,tmp2,tmp3,tmp1 - - .include "telemon30.inc" + .export _paper,_hires,_text,_circle,_curset, _switchOffCursor + .importzp sp,tmp2,tmp3,tmp1 + .import popa + .include "telemon30.inc" .proc _paper ldx #0 ; First window @@ -30,8 +30,11 @@ .endproc .proc _curset + jsr popa ; Pixel + jsr popa sta HRSX - sty HRSY + jsr popa + sta HRSY BRK_TELEMON XCURSE rts .endproc diff --git a/libsrc/telemon30/orixhdr.s b/libsrc/telemon30/orixhdr.s index 8744e86b0..1b0351885 100644 --- a/libsrc/telemon30/orixhdr.s +++ b/libsrc/telemon30/orixhdr.s @@ -1,5 +1,5 @@ ; -; Based on code by Debrune Jérôme <jede@oric.org> +; Based on code by Debrune Jérôme <jede@oric.org> ; 2016-03-17, Greg King ; @@ -17,18 +17,17 @@ .segment "ORIXHDR" - .byte $01, $00 ; + .byte $01, $00 ; - .byte "ORI" + .byte "ori" .byte $01 ; version - .byte $00,$00 ; mode - .byte $00,$00 ; cpu type + .byte $00,%00000000 ; 6502 only + .byte $00,$00 ; Extends .byte $00,$00 ; OS - .byte $00 ; reserved - .byte $00 ; auto - + .byte $00 ; reserved + .byte $00 ; auto .word __BASHEAD_START__ ; Address of start of file .word __MAIN_LAST__ - 1 ; Address of end of file diff --git a/libsrc/telemon30/write.s b/libsrc/telemon30/write.s index 32965fe3d..d762eb92c 100644 --- a/libsrc/telemon30/write.s +++ b/libsrc/telemon30/write.s @@ -27,6 +27,28 @@ sta ptr1 stx ptr1+1 jsr popax ; get fd and discard + + ; if fd=0001 then it stdout + + + cpx #0 + beq next + jmp L1 +next: + cmp #1 + beq L1 + + ; Here it's a file opened + lda ptr1 + sta PTR_READ_DEST + lda ptr1+1 + sta PTR_READ_DEST+1 + lda ptr3 + ldy ptr3+1 + BRK_TELEMON XFWRITE + rts + + L1: inc ptr2 bne L2 inc ptr2+1 From 6ed57af9fd44a4eb80d882f26d31c268c126db81 Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Sun, 29 Jan 2017 22:14:56 +0100 Subject: [PATCH 06/29] removing ch376.h --- include/ch376.h | 55 ------------------------------------------------- 1 file changed, 55 deletions(-) delete mode 100644 include/ch376.h diff --git a/include/ch376.h b/include/ch376.h deleted file mode 100644 index 9db801eaf..000000000 --- a/include/ch376.h +++ /dev/null @@ -1,55 +0,0 @@ - - -/* /// "Portable types" */ - - - - -/* /// "CH376 interface commands and constants" */ - -// Chip version -#define CH376_DATA_IC_VER 3 - -// Commands -#define CH376_CMD_NONE 0x00 -#define CH376_CMD_GET_IC_VER 0x01 -#define CH376_CMD_CHECK_EXIST 0x06 -#define CH376_CMD_SET_USB_MODE 0x15 -#define CH376_CMD_GET_STATUS 0x22 -#define CH376_CMD_RD_USB_DATA0 0x27 -#define CH376_CMD_WR_REQ_DATA 0x2d -#define CH376_CMD_SET_FILE_NAME 0x2f -#define CH376_CMD_DISK_MOUNT 0x31 -#define CH376_CMD_FILE_OPEN 0x32 -#define CH376_CMD_FILE_ENUM_GO 0x33 -#define CH376_CMD_FILE_CREATE 0x34 -#define CH376_CMD_FILE_CLOSE 0x36 -#define CH376_CMD_BYTE_LOCATE 0x39 -#define CH376_CMD_BYTE_READ 0x3a -#define CH376_CMD_BYTE_RD_GO 0x3b -#define CH376_CMD_BYTE_WRITE 0x3c -#define CH376_CMD_BYTE_WR_GO 0x3d -#define CH376_CMD_DISK_QUERY 0x3f -#define CH376_CMD_DISK_RD_GO 0x55 - -#define CH376_ARG_SET_USB_MODE_INVALID 0x00 -#define CH376_ARG_SET_USB_MODE_SD_HOST 0x03 -#define CH376_ARG_SET_USB_MODE_USB_HOST 0x06 - -// Status & errors -#define CH376_ERR_OPEN_DIR 0x41 -#define CH376_ERR_MISS_FILE 0x42 - -#define CH376_RET_SUCCESS 0x51 -#define CH376_RET_ABORT 0x5f - -#define CH376_INT_SUCCESS 0x14 -#define CH376_INT_DISK_READ 0x1d -#define CH376_INT_DISK_WRITE 0x1e - - -unsigned char ch376_check_exist(unsigned char value); -unsigned char ch376_ic_get_version(void); -void ch376_set_usb_mode(unsigned char value); -unsigned char ch376_disk_mount(void); - From 29881fb7c920a65004ee45a16e6769147367ce38 Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Sun, 29 Jan 2017 22:28:54 +0100 Subject: [PATCH 07/29] Revert --- libsrc/common/fread.s | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/libsrc/common/fread.s b/libsrc/common/fread.s index b87cc5cb4..91d692985 100644 --- a/libsrc/common/fread.s +++ b/libsrc/common/fread.s @@ -173,16 +173,13 @@ ; Read was ok, account for the pushed back character (if any). -@L8: - add pb +@L8: add pb bcc @L9 inx ; Check for end of file. -@L9: - - cmp #0 ; Zero bytes read? +@L9: cmp #0 ; Zero bytes read? bne @L10 cpx #0 bne @L10 @@ -195,10 +192,7 @@ ; Return the number of items successfully read. Since we've checked for ; bytes == 0 above, size cannot be zero here, so the division is safe. -@L10: - - - jsr pushax ; Push number of bytes read +@L10: jsr pushax ; Push number of bytes read ldy #5 jsr ldaxysp ; Get size jsr tosudivax ; bytes / size -> a/x From 0f8fb4d79d4fd91bea2f8659e0eabdc1db2b2de2 Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Sun, 29 Jan 2017 22:39:51 +0100 Subject: [PATCH 08/29] Merge with current version --- cfg/telemon30.cfg | 43 +++++++++++++++++++++++++++++++++++++++++++ src/ca65/main.c | 13 +++++++++---- src/cc65/main.c | 11 ++++++----- src/common/target.c | 2 ++ src/common/target.h | 1 + 5 files changed, 61 insertions(+), 9 deletions(-) create mode 100644 cfg/telemon30.cfg diff --git a/cfg/telemon30.cfg b/cfg/telemon30.cfg new file mode 100644 index 000000000..b9f0b4026 --- /dev/null +++ b/cfg/telemon30.cfg @@ -0,0 +1,43 @@ +SYMBOLS { + + __ORIXHDR__: type = import; + + __STACKSIZE__: type = weak, value = $0800; # 2K stack + + __RAMEND__: type = weak, value = $9800; +} +MEMORY { + ZP: file = "", define = yes, start = $00E0, size = $001A; + ORIXHDR: file = %O, type = ro, start = $0000, size = $001F; + BASHEAD: file = %O, define = yes, start = $0801, size = $000D; + MAIN: file = %O, define = yes, start = __BASHEAD_LAST__, size = __RAMEND__ - __MAIN_START__; + BSS: file = "", start = __ONCE_RUN__, size = __RAMEND__ - __STACKSIZE__ - __ONCE_RUN__; +} +SEGMENTS { + ZEROPAGE: load = ZP, type = zp; + ORIXHDR: load = ORIXHDR, type = ro; + STARTUP: load = MAIN, type = ro; + LOWCODE: load = MAIN, type = ro, optional = yes; + CODE: load = MAIN, type = ro; + RODATA: load = MAIN, type = ro; + DATA: load = MAIN, type = rw; + INIT: load = MAIN, type = rw; + ONCE: load = MAIN, type = ro, define = yes; + BASTAIL: load = MAIN, type = ro, optional = yes; + BSS: load = BSS, type = bss, define = yes; +} +FEATURES { + CONDES: type = constructor, + label = __CONSTRUCTOR_TABLE__, + count = __CONSTRUCTOR_COUNT__, + segment = ONCE; + CONDES: type = destructor, + label = __DESTRUCTOR_TABLE__, + count = __DESTRUCTOR_COUNT__, + segment = RODATA; + CONDES: type = interruptor, + label = __INTERRUPTOR_TABLE__, + count = __INTERRUPTOR_COUNT__, + segment = RODATA, + import = __CALLIRQ__; +} diff --git a/src/ca65/main.c b/src/ca65/main.c index 4aa60f2f0..91f652811 100644 --- a/src/ca65/main.c +++ b/src/ca65/main.c @@ -222,6 +222,10 @@ static void SetSys (const char* Sys) CBMSystem ("__C16__"); break; + case TGT_C65: + CBMSystem("__C65__"); + break; + case TGT_C64: CBMSystem ("__C64__"); break; @@ -623,11 +627,12 @@ static void OptVerbose (const char* Opt attribute ((unused)), -static void OptVersion (const char* Opt attribute ((unused)), - const char* Arg attribute ((unused))) -/* Print the assembler version */ +static void OptVersion(const char* Opt attribute((unused)), + const char* Arg attribute((unused))) + /* Print the assembler version */ { - fprintf (stderr, "ca65 V%s\n", GetVersionAsString ()); + fprintf(stderr, "%s V%s\n", ProgName, GetVersionAsString()); + exit(EXIT_SUCCESS); } diff --git a/src/cc65/main.c b/src/cc65/main.c index f25a44d69..b7abf959c 100644 --- a/src/cc65/main.c +++ b/src/cc65/main.c @@ -746,12 +746,13 @@ static void OptVerbose (const char* Opt attribute ((unused)), -static void OptVersion (const char* Opt attribute ((unused)), - const char* Arg attribute ((unused))) -/* Print the compiler version */ + +static void OptVersion(const char* Opt attribute((unused)), + const char* Arg attribute((unused))) + /* Print the compiler version */ { - fprintf (stderr, "cc65 V%s\n", GetVersionAsString ()); - exit (EXIT_SUCCESS); + fprintf(stderr, "%s V%s\n", ProgName, GetVersionAsString()); + exit(EXIT_SUCCESS); } diff --git a/src/common/target.c b/src/common/target.c index adbc080bf..31274d48a 100644 --- a/src/common/target.c +++ b/src/common/target.c @@ -209,6 +209,8 @@ static const TargetProperties PropertyTable[TGT_COUNT] = { { "sim65c02", CPU_65C02, BINFMT_BINARY, CTNone }, { "pce", CPU_HUC6280, BINFMT_BINARY, CTNone }, { "gamate", CPU_6502, BINFMT_BINARY, CTNone }, + { "c65", CPU_4510, BINFMT_BINARY, CTPET }, + }; /* Target system */ diff --git a/src/common/target.h b/src/common/target.h index 4bc00225d..93bcfe20d 100644 --- a/src/common/target.h +++ b/src/common/target.h @@ -82,6 +82,7 @@ typedef enum { TGT_SIM65C02, TGT_PCENGINE, TGT_GAMATE, + TGT_C65, TGT_COUNT /* Number of target systems */ } target_t; From 2697499b3c245a98871bb43380bdd068facd06c8 Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Sun, 29 Jan 2017 22:53:50 +0100 Subject: [PATCH 09/29] Fixing old pull request --- src/ca65/main.c | 14 +++++++------- src/cc65/main.c | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/ca65/main.c b/src/ca65/main.c index 91f652811..fd06f685d 100644 --- a/src/ca65/main.c +++ b/src/ca65/main.c @@ -222,14 +222,14 @@ static void SetSys (const char* Sys) CBMSystem ("__C16__"); break; - case TGT_C65: - CBMSystem("__C65__"); - break; - case TGT_C64: CBMSystem ("__C64__"); break; + case TGT_C65: + CBMSystem("__C65__"); + break; + case TGT_VIC20: CBMSystem ("__VIC20__"); break; @@ -628,11 +628,11 @@ static void OptVerbose (const char* Opt attribute ((unused)), static void OptVersion(const char* Opt attribute((unused)), - const char* Arg attribute((unused))) + const char* Arg attribute((unused))) /* Print the assembler version */ { - fprintf(stderr, "%s V%s\n", ProgName, GetVersionAsString()); - exit(EXIT_SUCCESS); + fprintf(stderr, "%s V%s\n", ProgName, GetVersionAsString()); + exit(EXIT_SUCCESS); } diff --git a/src/cc65/main.c b/src/cc65/main.c index b7abf959c..1fd670340 100644 --- a/src/cc65/main.c +++ b/src/cc65/main.c @@ -748,11 +748,11 @@ static void OptVerbose (const char* Opt attribute ((unused)), static void OptVersion(const char* Opt attribute((unused)), - const char* Arg attribute((unused))) + const char* Arg attribute((unused))) /* Print the compiler version */ { - fprintf(stderr, "%s V%s\n", ProgName, GetVersionAsString()); - exit(EXIT_SUCCESS); + fprintf(stderr, "%s V%s\n", ProgName, GetVersionAsString()); + exit(EXIT_SUCCESS); } From e21eca942b00e30c2d33c3220dbb1225e1751668 Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Sun, 29 Jan 2017 22:55:35 +0100 Subject: [PATCH 10/29] new pull fix --- src/ca65/main.c | 6 +++--- src/cc65/main.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ca65/main.c b/src/ca65/main.c index fd06f685d..cbd514bc3 100644 --- a/src/ca65/main.c +++ b/src/ca65/main.c @@ -627,9 +627,9 @@ static void OptVerbose (const char* Opt attribute ((unused)), -static void OptVersion(const char* Opt attribute((unused)), - const char* Arg attribute((unused))) - /* Print the assembler version */ +static void OptVersion (const char* Opt attribute((unused)), + const char* Arg attribute((unused))) +/* Print the assembler version */ { fprintf(stderr, "%s V%s\n", ProgName, GetVersionAsString()); exit(EXIT_SUCCESS); diff --git a/src/cc65/main.c b/src/cc65/main.c index 1fd670340..8fc774f87 100644 --- a/src/cc65/main.c +++ b/src/cc65/main.c @@ -747,9 +747,9 @@ static void OptVerbose (const char* Opt attribute ((unused)), -static void OptVersion(const char* Opt attribute((unused)), - const char* Arg attribute((unused))) - /* Print the compiler version */ +static void OptVersion (const char* Opt attribute((unused)), + const char* Arg attribute((unused))) +/* Print the compiler version */ { fprintf(stderr, "%s V%s\n", ProgName, GetVersionAsString()); exit(EXIT_SUCCESS); From bd82bf6a7fe9b7644dadb579f1fe4b72c184e9eb Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Sun, 29 Jan 2017 22:59:53 +0100 Subject: [PATCH 11/29] Fix --- src/ca65/main.c | 2 +- src/cc65/main.c | 4 ++-- src/common/target.c | 8 ++++---- src/common/target.h | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/ca65/main.c b/src/ca65/main.c index cbd514bc3..ff321d87d 100644 --- a/src/ca65/main.c +++ b/src/ca65/main.c @@ -631,7 +631,7 @@ static void OptVersion (const char* Opt attribute((unused)), const char* Arg attribute((unused))) /* Print the assembler version */ { - fprintf(stderr, "%s V%s\n", ProgName, GetVersionAsString()); + fprintf(stderr, "%s V%s\n", ProgName, GetVersionAsString ()); exit(EXIT_SUCCESS); } diff --git a/src/cc65/main.c b/src/cc65/main.c index 8fc774f87..e4e5ce81f 100644 --- a/src/cc65/main.c +++ b/src/cc65/main.c @@ -751,8 +751,8 @@ static void OptVersion (const char* Opt attribute((unused)), const char* Arg attribute((unused))) /* Print the compiler version */ { - fprintf(stderr, "%s V%s\n", ProgName, GetVersionAsString()); - exit(EXIT_SUCCESS); + fprintf (stderr, "%s V%s\n", ProgName, GetVersionAsString ()); + exit (EXIT_SUCCESS); } diff --git a/src/common/target.c b/src/common/target.c index 31274d48a..dfbe4d354 100644 --- a/src/common/target.c +++ b/src/common/target.c @@ -152,6 +152,7 @@ static const TargetEntry TargetMap[] = { { "c128", TGT_C128 }, { "c16", TGT_C16 }, { "c64", TGT_C64 }, + { "c65", TGT_C65 }, { "cbm510", TGT_CBM510 }, { "cbm610", TGT_CBM610 }, { "gamate", TGT_GAMATE }, @@ -200,8 +201,8 @@ static const TargetProperties PropertyTable[TGT_COUNT] = { { "geos-apple", CPU_65C02, BINFMT_BINARY, CTNone }, { "lunix", CPU_6502, BINFMT_O65, CTNone }, { "atmos", CPU_6502, BINFMT_BINARY, CTNone }, - { "telemon24", CPU_6502, BINFMT_BINARY, CTNone }, - { "telemon30", CPU_6502, BINFMT_BINARY, CTNone }, + { "telemon24", CPU_6502, BINFMT_BINARY, CTNone }, + { "telemon30", CPU_6502, BINFMT_BINARY, CTNone }, { "nes", CPU_6502, BINFMT_BINARY, CTNone }, { "supervision", CPU_65SC02, BINFMT_BINARY, CTNone }, { "lynx", CPU_65SC02, BINFMT_BINARY, CTNone }, @@ -209,8 +210,7 @@ static const TargetProperties PropertyTable[TGT_COUNT] = { { "sim65c02", CPU_65C02, BINFMT_BINARY, CTNone }, { "pce", CPU_HUC6280, BINFMT_BINARY, CTNone }, { "gamate", CPU_6502, BINFMT_BINARY, CTNone }, - { "c65", CPU_4510, BINFMT_BINARY, CTPET }, - + { "c65", CPU_4510, BINFMT_BINARY, CTPET }, }; /* Target system */ diff --git a/src/common/target.h b/src/common/target.h index 93bcfe20d..2b0a4e196 100644 --- a/src/common/target.h +++ b/src/common/target.h @@ -82,7 +82,7 @@ typedef enum { TGT_SIM65C02, TGT_PCENGINE, TGT_GAMATE, - TGT_C65, + TGT_C65, TGT_COUNT /* Number of target systems */ } target_t; From db3b6603e510741faee19da56cebfaabff3d33d5 Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Sun, 29 Jan 2017 23:03:01 +0100 Subject: [PATCH 12/29] Fix --- src/ca65/main.c | 12 ++++++------ src/cc65/main.c | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/ca65/main.c b/src/ca65/main.c index ff321d87d..8022b7818 100644 --- a/src/ca65/main.c +++ b/src/ca65/main.c @@ -226,9 +226,9 @@ static void SetSys (const char* Sys) CBMSystem ("__C64__"); break; - case TGT_C65: - CBMSystem("__C65__"); - break; + case TGT_C65: + CBMSystem("__C65__"); + break; case TGT_VIC20: CBMSystem ("__VIC20__"); @@ -627,11 +627,11 @@ static void OptVerbose (const char* Opt attribute ((unused)), -static void OptVersion (const char* Opt attribute((unused)), - const char* Arg attribute((unused))) +static void OptVersion (const char* Opt attribute ((unused)), + const char* Arg attribute ((unused))) /* Print the assembler version */ { - fprintf(stderr, "%s V%s\n", ProgName, GetVersionAsString ()); + fprintf (stderr, "%s V%s\n", ProgName, GetVersionAsString ()); exit(EXIT_SUCCESS); } diff --git a/src/cc65/main.c b/src/cc65/main.c index e4e5ce81f..6847c4b14 100644 --- a/src/cc65/main.c +++ b/src/cc65/main.c @@ -747,8 +747,8 @@ static void OptVerbose (const char* Opt attribute ((unused)), -static void OptVersion (const char* Opt attribute((unused)), - const char* Arg attribute((unused))) +static void OptVersion (const char* Opt attribute ((unused)), + const char* Arg attribute ((unused))) /* Print the compiler version */ { fprintf (stderr, "%s V%s\n", ProgName, GetVersionAsString ()); From 858e95250586aa6ba9feb478a07accfd4ced42ae Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Sun, 29 Jan 2017 23:05:18 +0100 Subject: [PATCH 13/29] Fix --- src/ca65/main.c | 2 +- src/cc65/main.c | 1 - src/common/target.c | 4 ++-- src/common/target.h | 4 ++-- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/ca65/main.c b/src/ca65/main.c index 8022b7818..1e0c5996f 100644 --- a/src/ca65/main.c +++ b/src/ca65/main.c @@ -227,7 +227,7 @@ static void SetSys (const char* Sys) break; case TGT_C65: - CBMSystem("__C65__"); + CBMSystem ("__C65__"); break; case TGT_VIC20: diff --git a/src/cc65/main.c b/src/cc65/main.c index 6847c4b14..b0c9261fe 100644 --- a/src/cc65/main.c +++ b/src/cc65/main.c @@ -746,7 +746,6 @@ static void OptVerbose (const char* Opt attribute ((unused)), - static void OptVersion (const char* Opt attribute ((unused)), const char* Arg attribute ((unused))) /* Print the compiler version */ diff --git a/src/common/target.c b/src/common/target.c index dfbe4d354..67e4ad51b 100644 --- a/src/common/target.c +++ b/src/common/target.c @@ -147,7 +147,7 @@ static const TargetEntry TargetMap[] = { { "atari", TGT_ATARI }, { "atari5200", TGT_ATARI5200 }, { "atarixl", TGT_ATARIXL }, - { "atmos", TGT_ATMOS }, + { "atmos", TGT_ATMOS }, { "bbc", TGT_BBC }, { "c128", TGT_C128 }, { "c16", TGT_C16 }, @@ -172,7 +172,7 @@ static const TargetEntry TargetMap[] = { { "sim65c02", TGT_SIM65C02 }, { "supervision", TGT_SUPERVISION }, { "telemon24", TGT_TELEMON24 }, - { "telemon30", TGT_TELEMON30 }, + { "telemon30", TGT_TELEMON30 }, { "vic20", TGT_VIC20 }, }; #define MAP_ENTRY_COUNT (sizeof (TargetMap) / sizeof (TargetMap[0])) diff --git a/src/common/target.h b/src/common/target.h index 2b0a4e196..68c0953fe 100644 --- a/src/common/target.h +++ b/src/common/target.h @@ -73,8 +73,8 @@ typedef enum { TGT_GEOS_APPLE, TGT_LUNIX, TGT_ATMOS, - TGT_TELEMON24, - TGT_TELEMON30, + TGT_TELEMON24, + TGT_TELEMON30, TGT_NES, TGT_SUPERVISION, TGT_LYNX, From 06b2b83ab298e5a8898d2d588c0e94daea2b7308 Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Sun, 29 Jan 2017 23:18:32 +0100 Subject: [PATCH 14/29] Correcting spaces --- libsrc/telemon30/_read.s | 36 +++--- libsrc/telemon30/ch376.s | 272 ++++++++++++++++++--------------------- 2 files changed, 139 insertions(+), 169 deletions(-) diff --git a/libsrc/telemon30/_read.s b/libsrc/telemon30/_read.s index e8bcc3fd0..ee822f1fd 100644 --- a/libsrc/telemon30/_read.s +++ b/libsrc/telemon30/_read.s @@ -12,36 +12,30 @@ ; int read (int fd, void* buf, unsigned count); .proc _read - - sta ptr1 ; count - stx ptr1+1 ; count - jsr popax ; get buf + sta ptr1 ; count + stx ptr1+1 ; count + jsr popax ; get buf - sta PTR_READ_DEST - stx PTR_READ_DEST+1 - sta ptr2 ; in order to calculate nb of bytes read - stx ptr2+1 ; + sta PTR_READ_DEST + stx PTR_READ_DEST+1 + sta ptr2 ; in order to calculate nb of bytes read + stx ptr2+1 ; - ;jsr popax ; fp pointer don't care in this version + ; jsr popax ; fp pointer don't care in this version - lda ptr1 ; - ldy ptr1+1 ; + lda ptr1 ; + ldy ptr1+1 ; BRK_TELEMON XFREAD ; calls telemon30 routine ; compute nb of bytes read - lda PTR_READ_DEST+1 + lda PTR_READ_DEST+1 sec - sbc ptr2+1 - tax - lda PTR_READ_DEST + sbc ptr2+1 + tax + lda PTR_READ_DEST sec - sbc ptr2 - - - + sbc ptr2 ; Here A and X contains number of bytes read - rts - .endproc diff --git a/libsrc/telemon30/ch376.s b/libsrc/telemon30/ch376.s index 97245add9..460a70052 100644 --- a/libsrc/telemon30/ch376.s +++ b/libsrc/telemon30/ch376.s @@ -77,108 +77,107 @@ CH376_DISK_CAPACITY := $3E CH376_DISK_RD_GO := $55 .proc _ch376_file_close - lda #CH376_FILE_CLOSE - sta CH376_COMMAND - jsr _ch376_wait_response + lda #CH376_FILE_CLOSE + sta CH376_COMMAND + jsr _ch376_wait_response rts .endproc .proc _ch376_seek_file - ldx #CH376_BYTE_LOCATE - stx CH376_COMMAND - sta CH376_DATA - sty CH376_DATA - lda #$00 ; Don't manage 32 bits length - sta CH376_DATA - sta CH376_DATA - jsr _ch376_wait_response + ldx #CH376_BYTE_LOCATE + stx CH376_COMMAND + sta CH376_DATA + sty CH376_DATA + lda #$00 ; Don't manage 32 bits length + sta CH376_DATA + sta CH376_DATA + jsr _ch376_wait_response rts .endproc ; void ch376_set_file_name(char *filename) .proc _ch376_set_file_name - sta ptr1 - stx ptr1+1 - lda #CH376_SET_FILE_NAME ;$2f - sta CH376_COMMAND - ldy #0 + sta ptr1 + stx ptr1+1 + lda #CH376_SET_FILE_NAME ;$2f + sta CH376_COMMAND + ldy #0 loop: - lda (ptr1),y ; replace by bufnom - beq end ; we reached 0 value - ;BRK_TELEMON XMINMA - sta CH376_DATA + lda (ptr1),y ; replace by bufnom + beq end ; we reached 0 value + BRK_TELEMON XMINMA + sta CH376_DATA iny - cpy #13 ; because we don't manage longfilename shortname =11 - bne loop + cpy #13 ; because we don't manage longfilename shortname =11 + bne loop end: - sta CH376_DATA + sta CH376_DATA rts .endproc ; char _ch376_file_open(); .proc _ch376_file_open - lda #CH376_FILE_OPEN ; $32 - sta CH376_COMMAND - jsr _ch376_wait_response -; ldx #0 + lda #CH376_FILE_OPEN ; $32 + sta CH376_COMMAND + jsr _ch376_wait_response rts .endproc - ;CMD_GET_FILE_SIZE + .proc _ch376_get_file_size - lda #CH376_GET_FILE_SIZE - sta CH376_COMMAND - lda #$68 - sta CH376_DATA - ; store file leng - lda CH376_DATA - sta tmp1 - lda CH376_DATA - sta tmp1+1 - lda CH376_DATA - sta tmp2 - lda CH376_DATA - sta tmp2+1 + lda #CH376_GET_FILE_SIZE + sta CH376_COMMAND + lda #$68 + sta CH376_DATA + ; store file length 32 bits + lda CH376_DATA + sta tmp1 + lda CH376_DATA + sta tmp1+1 + lda CH376_DATA + sta tmp2 + lda CH376_DATA + sta tmp2+1 rts .endproc ; void ch376_reset(); .proc _ch376_reset - lda #CH376_RESET_ALL ; 5 - sta CH376_COMMAND + lda #CH376_RESET_ALL ; 5 + sta CH376_COMMAND ; waiting - ldy #0 - ldx #0 + ldy #0 + ldx #0 loop: nop inx - bne loop + bne loop iny - bne loop + bne loop rts .endproc ; char ch376_check_exist(char value); .proc _ch376_check_exist - sta tmp1 - lda #CH376_CHECK_EXIST ; - sta CH376_COMMAND - lda tmp1 - sta CH376_DATA - lda CH376_DATA + sta tmp1 + lda #CH376_CHECK_EXIST ; + sta CH376_COMMAND + lda tmp1 + sta CH376_DATA + lda CH376_DATA rts .endproc ; char ch376_ic_get_version(void) .proc _ch376_ic_get_version - lda #CH376_GET_IC_VER - sta CH376_COMMAND - ldx #0 - lda CH376_DATA + lda #CH376_GET_IC_VER + sta CH376_COMMAND + ldx #0 + lda CH376_DATA rts .endproc @@ -186,45 +185,45 @@ loop: .proc _ch376_set_usb_mode ; CH376_SET_USB_MODE_CODE_USB_HOST_SOF_PACKAGE_AUTOMATICALLY - ldx #CH376_SET_USB_MODE ; $15 - stx CH376_COMMAND - sta CH376_DATA + ldx #CH376_SET_USB_MODE ; $15 + stx CH376_COMMAND + sta CH376_DATA rts .endproc ; void ch376_set_bytes_write(int value); .proc _ch376_set_bytes_write - ldy #CH376_BYTE_WRITE - sty CH376_COMMAND - sta CH376_DATA - stx CH376_DATA - lda #0 - sta CH376_DATA - sta CH376_DATA - jsr _ch376_wait_response + ldy #CH376_BYTE_WRITE + sty CH376_COMMAND + sta CH376_DATA + stx CH376_DATA + lda #0 + sta CH376_DATA + sta CH376_DATA + jsr _ch376_wait_response rts .endproc .proc _ch376_set_bytes_read - ldy #CH376_BYTE_READ - sty CH376_COMMAND + ldy #CH376_BYTE_READ + sty CH376_COMMAND ; Storing 32 bits value - sta CH376_DATA - stx CH376_DATA - lda #0 - sta CH376_DATA - sta CH376_DATA - jsr _ch376_wait_response + sta CH376_DATA + stx CH376_DATA + lda #0 + sta CH376_DATA + sta CH376_DATA + jsr _ch376_wait_response rts .endproc ; char ch376_disk_mount(); .proc _ch376_disk_mount - lda #CH376_DISK_MOUNT ; $31 - sta CH376_COMMAND - jsr _ch376_wait_response + lda #CH376_DISK_MOUNT ; $31 + sta CH376_COMMAND + jsr _ch376_wait_response ; if we read data value, we have then length of the volume name - ldx #0 + ldx #0 rts .endproc @@ -233,89 +232,87 @@ loop: .proc _ch376_wait_response ; 1 return 1 if usb controller does not respond ; else A contains answer of the controller - ldy #$ff + ldy #$ff loop3: - ldx #$ff ; don't decrease this counter. Because ch376 won't respond if there is a lower value + ldx #$ff ; don't decrease this counter. Because ch376 won't respond if there is a lower value loop: - lda CH376_COMMAND - and #%10000000 - cmp #128 - bne no_error + lda CH376_COMMAND + and #%10000000 + cmp #128 + bne no_error dex - bne loop + bne loop dey - bne loop3 + bne loop3 ; error is here rts no_error: - lda #CH376_GET_STATUS - sta CH376_COMMAND - lda CH376_DATA + lda #CH376_GET_STATUS + sta CH376_COMMAND + lda CH376_DATA rts .endproc .proc _ch376_fread ; use ptr1 to count bytes - jsr _ch376_set_bytes_read + jsr _ch376_set_bytes_read continue: - cmp #CH376_USB_INT_DISK_READ ; something to read - beq we_read - cmp #CH376_USB_INT_SUCCESS ; finished - beq finished + cmp #CH376_USB_INT_DISK_READ ; something to read + beq we_read + cmp #CH376_USB_INT_SUCCESS ; finished + beq finished ; TODO in A : $ff X: $ff - lda #0 + lda #0 tax rts we_read: - lda #CH376_RD_USB_DATA0 - sta CH376_COMMAND + lda #CH376_RD_USB_DATA0 + sta CH376_COMMAND - lda CH376_DATA ; contains length read - sta tmp2; Number of bytes to read + lda CH376_DATA ; contains length read + sta tmp2; Number of bytes to read ldy #0 loop: - lda CH376_DATA ; read the data - sta (PTR_READ_DEST),y + lda CH376_DATA ; read the data + sta (PTR_READ_DEST),y iny - cpy tmp2 - bne loop + cpy tmp2 + bne loop tya clc - adc PTR_READ_DEST - bcc next - inc PTR_READ_DEST+1 + adc PTR_READ_DEST + bcc next + inc PTR_READ_DEST+1 next: - sta PTR_READ_DEST + sta PTR_READ_DEST - lda #CH376_BYTE_RD_GO - sta CH376_COMMAND - jsr _ch376_wait_response - jmp continue + lda #CH376_BYTE_RD_GO + sta CH376_COMMAND + jsr _ch376_wait_response + jmp continue finished: ; TODO return bytes read - lda tmp1 - - ldx tmp1+1 - + lda tmp1 + ldx tmp1+1 rts .endproc ; void _ch376_fwrite(void *ptr,int number) .proc _ch376_fwrite - ; use ptr1 to count bytes - sta ptr2 - stx ptr2+1 + ; use ptr1 to count bytes + sta ptr2 + stx ptr2+1 - jsr popax - sta PTR_READ_DEST - stx PTR_READ_DEST+1 + jsr popax + sta PTR_READ_DEST + stx PTR_READ_DEST+1 - lda ptr2 - ldx ptr2+1 - jsr _ch376_set_bytes_write + lda ptr2 + ldx ptr2+1 + jsr _ch376_set_bytes_write ;cmp #CH376_USB_INT_SUCCESS ;beq finished ;jsr popax @@ -346,26 +343,7 @@ loop: sta CH376_DATA ; read the data dec tmp2 bne loop -; dec ptr2 - ;bne continue3 - ;dec ptr2+1 - ;bne continue3 -;continue3 -; lda ptr2+1 - ;bne continue2 - ;lda ptr2 - ;beq finished -;continue2 -; iny -; cpy tmp2 -; bne loop -; tya -; clc -; adc PTR_READ_DEST -; bcc next -; inc PTR_READ_DEST+1 -;next: -; sta PTR_READ_DEST + lda #CH376_BYTE_WR_GO sta CH376_COMMAND @@ -380,8 +358,6 @@ finished: rts .endproc - - .proc _ch376_file_create lda #CH376_FILE_CREATE sta CH376_COMMAND From b5fef66f37d3a6f8419f32177f27a01108091d48 Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Tue, 31 Jan 2017 22:09:14 +0100 Subject: [PATCH 15/29] Merge telemon24 and telemon30 into telestrat target. Cleaning, and replace tab to spaces Converting hex lowercase value into uppercase char. Changing := and = when it was needed --- asminc/telemon24.inc | 68 ---- asminc/{telemon30.inc => telestrat.inc} | 103 +++-- cfg/telemon24.cfg | 43 -- cfg/{telemon30.cfg => telestrat.cfg} | 0 doc/telemon24.sgml | 42 -- doc/{telemon30.sgml => telestrat.sgml} | 0 include/telemon.h | 58 --- include/{telemon30.h => telestrat.h} | 0 libsrc/Makefile | 3 +- libsrc/telemon24/crt0.s | 101 ----- libsrc/telemon24/hires.s | 22 -- libsrc/telemon24/mainargs.s | 36 -- libsrc/telemon24/print.s | 25 -- libsrc/telemon24/tapehdr.s | 36 -- libsrc/telemon24/write.s | 59 --- libsrc/telemon30/_close.s | 17 - libsrc/telemon30/_read.s | 41 -- libsrc/telemon30/_scrsize.s | 19 - libsrc/telemon30/ch376.s | 366 ------------------ libsrc/telemon30/ctype.s | 299 -------------- libsrc/telemon30/graphics.s | 54 --- libsrc/telemon30/keyboard.s | 13 - libsrc/telemon30/oserrlist.s | 75 ---- libsrc/telemon30/oserror.s | 17 - libsrc/telemon30/print.s | 21 - libsrc/telemon30/sound.s | 45 --- libsrc/telemon30/sysuname.s | 46 --- libsrc/telestrat/ch376.s | 344 ++++++++++++++++ libsrc/telestrat/close.s | 18 + libsrc/{telemon30 => telestrat}/crt0.s | 12 +- libsrc/{telemon24 => telestrat}/ctype.s | 0 libsrc/telestrat/graphics.s | 58 +++ libsrc/telestrat/keyboard.s | 14 + libsrc/{telemon30 => telestrat}/mainargs.s | 29 +- libsrc/{telemon30 => telestrat}/mym.s | 2 +- .../{telemon30/_open.s => telestrat/open.s} | 21 +- libsrc/{telemon30 => telestrat}/orixhdr.s | 22 +- libsrc/{telemon24 => telestrat}/oserrlist.s | 0 libsrc/{telemon24 => telestrat}/oserror.s | 0 libsrc/telestrat/print.s | 16 + libsrc/telestrat/read.s | 43 ++ .../_scrsize.s => telestrat/scrsize.s} | 2 +- libsrc/telestrat/sound.s | 42 ++ libsrc/{telemon24 => telestrat}/sysuname.s | 0 libsrc/{telemon30 => telestrat}/write.s | 14 +- src/ca65/main.c | 8 +- src/cc65/main.c | 8 +- src/common/target.c | 6 +- src/common/target.h | 3 +- 49 files changed, 629 insertions(+), 1642 deletions(-) delete mode 100644 asminc/telemon24.inc rename asminc/{telemon30.inc => telestrat.inc} (69%) delete mode 100644 cfg/telemon24.cfg rename cfg/{telemon30.cfg => telestrat.cfg} (100%) delete mode 100644 doc/telemon24.sgml rename doc/{telemon30.sgml => telestrat.sgml} (100%) delete mode 100644 include/telemon.h rename include/{telemon30.h => telestrat.h} (100%) delete mode 100644 libsrc/telemon24/crt0.s delete mode 100644 libsrc/telemon24/hires.s delete mode 100644 libsrc/telemon24/mainargs.s delete mode 100644 libsrc/telemon24/print.s delete mode 100644 libsrc/telemon24/tapehdr.s delete mode 100644 libsrc/telemon24/write.s delete mode 100644 libsrc/telemon30/_close.s delete mode 100644 libsrc/telemon30/_read.s delete mode 100644 libsrc/telemon30/_scrsize.s delete mode 100644 libsrc/telemon30/ch376.s delete mode 100644 libsrc/telemon30/ctype.s delete mode 100644 libsrc/telemon30/graphics.s delete mode 100644 libsrc/telemon30/keyboard.s delete mode 100644 libsrc/telemon30/oserrlist.s delete mode 100644 libsrc/telemon30/oserror.s delete mode 100644 libsrc/telemon30/print.s delete mode 100644 libsrc/telemon30/sound.s delete mode 100644 libsrc/telemon30/sysuname.s create mode 100644 libsrc/telestrat/ch376.s create mode 100644 libsrc/telestrat/close.s rename libsrc/{telemon30 => telestrat}/crt0.s (85%) rename libsrc/{telemon24 => telestrat}/ctype.s (100%) create mode 100644 libsrc/telestrat/graphics.s create mode 100644 libsrc/telestrat/keyboard.s rename libsrc/{telemon30 => telestrat}/mainargs.s (90%) rename libsrc/{telemon30 => telestrat}/mym.s (99%) rename libsrc/{telemon30/_open.s => telestrat/open.s} (65%) rename libsrc/{telemon30 => telestrat}/orixhdr.s (56%) rename libsrc/{telemon24 => telestrat}/oserrlist.s (100%) rename libsrc/{telemon24 => telestrat}/oserror.s (100%) create mode 100644 libsrc/telestrat/print.s create mode 100644 libsrc/telestrat/read.s rename libsrc/{telemon24/_scrsize.s => telestrat/scrsize.s} (85%) create mode 100644 libsrc/telestrat/sound.s rename libsrc/{telemon24 => telestrat}/sysuname.s (100%) rename libsrc/{telemon30 => telestrat}/write.s (86%) diff --git a/asminc/telemon24.inc b/asminc/telemon24.inc deleted file mode 100644 index 0b58d63a6..000000000 --- a/asminc/telemon24.inc +++ /dev/null @@ -1,68 +0,0 @@ -; -; Oric Telemon definition -; Telemon 2.4 -; - - -; --------------------------------------------------------------------------- -; Constants - -SCREEN_XSIZE = 40 ; screen columns -SCREEN_YSIZE = 28 ; screen rows - -FUNCTKEY = $A5 - -FNAME_LEN = 11 ; maximum length of file-name - - -; --------------------------------------------------------------------------- -; Zero page - - - - -; --------------------------------------------------------------------------- -; Low memory - - - - -; --------------------------------------------------------------------------- -; I/O locations - -; 6522 -.struct VIA ; Versatile Interface Adapter - .res $0300 -PRB .byte ; Port Register B -PRA .byte ; Port Register A -DDRB .byte ; Data Direction Register B -DDRA .byte ; Data Direction Register A -T1 .word ; Timer 1 -T1L .word ; Timer 1 Latch -T2 .word ; Timer 2 -SR .byte ; Shift Register -ACR .byte ; Auxiliary Control Register -PCR .byte ; Peripheral Control Register -IFR .byte ; Interrupt Flags Register -IER .byte ; Interrupt Enable Register -PRA2 .byte ; Port Register A without handshaking -.endstruct - -; 6551 -.struct ACIA ; Asynchronous Communications Interface Adapter - .res $031C -DATA .byte -STATUS .byte -CMD .byte ; Command register -CTRL .byte ; Control register -.endstruct - -SCREEN := $BB80 - - -; --------------------------------------------------------------------------- -; ROM entries - -XWR0 := $10 -XWSTR0 := $14 - diff --git a/asminc/telemon30.inc b/asminc/telestrat.inc similarity index 69% rename from asminc/telemon30.inc rename to asminc/telestrat.inc index acfd7e919..fedda1946 100644 --- a/asminc/telemon30.inc +++ b/asminc/telestrat.inc @@ -1,6 +1,7 @@ ; ; Oric Telemon definition -; Telemon 2.4 +; Telemon 2.4 & Telemon 3.0 +; For telemon 3.0 check http://orix.oric.org ; @@ -18,6 +19,24 @@ FNAME_LEN = 11 ; maximum length of file-name ; --------------------------------------------------------------------------- ; Zero page +; --------------------------------------------------------------------------- +; Page 00 +RES := $00 +RESB := $02 + +TR0 := $0C +TR1 := $0D + +PTR_READ_DEST := $2D ; used for XFREAD and XWRITE only in telemon 3.0 + +HRSX := $46 +HRSY := $47 + +HRS1 := $4D +HRS2 := $4F +HRS3 := $51 +HRS4 := $53 +HRS5 := $55 @@ -82,69 +101,47 @@ SCREEN := $BB80 ; ROM entries ; primitives telemon 2.4 -XRD0 := $08 -XRDW0 := $0c -XWR0 := $10 -XWSTR0 := $14 -XTEXT := $19 -XHIRES := $1A -XMINMA := $1f -XFREAD := $27 ; only in TELEMON 3.0 -XOPEN := $30 ; only in TELEMON 3.0 -XCOSCR := $34 ; switch off cursor -XCSSCR := $35 ; switch on cursor -XCLOSE := $3a ; Close file -XFWRITE:= $3b ; write - -XSONPS := $40 -XOUPS := $42 -XPLAY := $43 -XSOUND := $44 -XMUSIC := $45 -XZAP := $46 -XSHOOT := $47 -XCIRCL := $8f -XCURSE := $90 -XEXPLO := $9c -XPING := $9d -XPAPER := $92 -XINK := $93 - - -; --------------------------------------------------------------------------- -; Page 00 -RES := $00 -RESB := $02 - -TR0 := $0c -TR1 := $0d - -PTR_READ_DEST := $2c ; used for XFREAD and XWRITE - -HRSX := $46 -HRSY := $47 - -HRS1 := $4D -HRS2 := $4F -HRS3 := $51 -HRS4 := $53 -HRS5 := $55 +XRD0 = $08 +XRDW0 = $0C +XWR0 = $10 +XWSTR0 = $14 +XTEXT = $19 +XHIRES = $1A +XMINMA = $1F +XFREAD = $27 ; only in TELEMON 3.0 +XOPEN = $30 ; only in TELEMON 3.0 +XCOSCR = $34 ; switch off cursor +XCSSCR = $35 ; switch on cursor +XCLOSE = $3A ; only in TELEMON 3.0 Close file +XFWRITE = $3B ; only in TELEMON 3.0 write file +XSONPS = $40 +XOUPS = $42 +XPLAY = $43 +XSOUND = $44 +XMUSIC = $45 +XZAP = $46 +XSHOOT = $47 +XCIRCL = $8F +XCURSE = $90 +XEXPLO = $9C +XPING = $9D +XPAPER = $92 +XINK = $93 ; --------------------------------------------------------------------------- ; Page $500 -BUFNOM := $517 -BUFEDT := $590 +BUFNOM := $517 +BUFEDT := $590 MAX_BUFEDT_LENGTH=110 ; Hardware -CH376_DATA :=$340 -CH376_COMMAND :=$341 +CH376_DATA :=$340 +CH376_COMMAND :=$341 ; MACRO - .macro BRK_TELEMON value .byte $00,value .endmacro diff --git a/cfg/telemon24.cfg b/cfg/telemon24.cfg deleted file mode 100644 index b76350868..000000000 --- a/cfg/telemon24.cfg +++ /dev/null @@ -1,43 +0,0 @@ -SYMBOLS { - - __ORIXHDR__: type = import; - - __STACKSIZE__: type = weak, value = $0800; # 2K stack - - __RAMEND__: type = weak, value = $9800 + $1C00 ; -} -MEMORY { - ZP: file = "", define = yes, start = $00E2, size = $001A; - ORIXHDR: file = %O, type = ro, start = $0000, size = $001F; - BASHEAD: file = %O, define = yes, start = $0801, size = $000D; - MAIN: file = %O, define = yes, start = __BASHEAD_LAST__, size = __RAMEND__ - __MAIN_START__; - BSS: file = "", start = __ONCE_RUN__, size = __RAMEND__ - __STACKSIZE__ - __ONCE_RUN__; -} -SEGMENTS { - ZEROPAGE: load = ZP, type = zp; - ORIXHDR: load = ORIXHDR, type = ro; - STARTUP: load = MAIN, type = ro; - LOWCODE: load = MAIN, type = ro, optional = yes; - CODE: load = MAIN, type = ro; - RODATA: load = MAIN, type = ro; - DATA: load = MAIN, type = rw; - INIT: load = MAIN, type = rw; - ONCE: load = MAIN, type = ro, define = yes; - BASTAIL: load = MAIN, type = ro, optional = yes; - BSS: load = BSS, type = bss, define = yes; -} -FEATURES { - CONDES: type = constructor, - label = __CONSTRUCTOR_TABLE__, - count = __CONSTRUCTOR_COUNT__, - segment = ONCE; - CONDES: type = destructor, - label = __DESTRUCTOR_TABLE__, - count = __DESTRUCTOR_COUNT__, - segment = RODATA; - CONDES: type = interruptor, - label = __INTERRUPTOR_TABLE__, - count = __INTERRUPTOR_COUNT__, - segment = RODATA, - import = __CALLIRQ__; -} diff --git a/cfg/telemon30.cfg b/cfg/telestrat.cfg similarity index 100% rename from cfg/telemon30.cfg rename to cfg/telestrat.cfg diff --git a/doc/telemon24.sgml b/doc/telemon24.sgml deleted file mode 100644 index b4e1befa1..000000000 --- a/doc/telemon24.sgml +++ /dev/null @@ -1,42 +0,0 @@ -<!doctype linuxdoc system> - -<article> - -<title>Oric Telemon 2.4 -specific information for cc65 -<author> - -<url url="mailto:greg.king5@verizon.net" name="Greg King"> -<date>2017-01-22 - -<abstract> -An overview over the Telemon 3.0 runtime system as it is implemented for the cc65 C -compiler. -</abstract> - -<!-- Table of contents --> -<toc> - - - -<sect>License<p> - -This software is provided 'as-is', without any expressed or implied -warranty. In no event will the authors be held liable for any damages -arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - -<enum> -<item> The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. -<item> Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. -<item> This notice may not be removed or altered from any source - distribution. -</enum> - -</article> diff --git a/doc/telemon30.sgml b/doc/telestrat.sgml similarity index 100% rename from doc/telemon30.sgml rename to doc/telestrat.sgml diff --git a/include/telemon.h b/include/telemon.h deleted file mode 100644 index 70033a9ad..000000000 --- a/include/telemon.h +++ /dev/null @@ -1,58 +0,0 @@ - -void print (char *); - -void hires(); -void text(); -void oups(); -void ping(); -void zap(); -void shoot(); -void explode(); - -void paper(char color); -void ink(char color); - -void kbdclick1(); - - - -void curset(char x,char y); -void circle(char rayon); - -char key(void); - - -/* PEEK, POKE, DEEK, DOKE */ - -#define POKE(addr,val) (*(unsigned char*) (addr) = (val)) - - -#define PCHN_1 001 -#define PCHN_2 002 -#define PCHN_12 003 -#define PCHN_3 004 -#define PCHN_13 005 -#define PCHN_23 006 -#define PCHN_123 007 - -#define ENV_DECAY 001 /* \_________ envelope */ -#define ENV_ATTACK_CUT 002 /* /_________ envelope */ -#define ENV_SAW_DOWN 003 /* \\\\\\\\\\ envelope */ -#define ENV_WAVE 004 /* /\/\/\/\/\ envelope */ -#define ENV_DECAY_CONT 005 /* \~~~~~~~~~ envelope */ -#define ENV_SAW_UP 006 /* ////////// envelope */ -#define ENV_ATTACK_CONT 007 /* /~~~~~~~~~ envelope */ - -#define VOL_ENVELOPE 0x0 -#define VOL_QUIETEST 0x1 -#define VOL_LOUDEST 0xe - -extern int play(int soundchanels,int noisechanels,int envelop,int volume); - - -/* Play a musical tone through the selected channel. */ - -#define CHAN_1 1 -#define CHAN_2 2 -#define CHAN_3 3 - diff --git a/include/telemon30.h b/include/telestrat.h similarity index 100% rename from include/telemon30.h rename to include/telestrat.h diff --git a/libsrc/Makefile b/libsrc/Makefile index 0342a8ca4..8bcbe4410 100644 --- a/libsrc/Makefile +++ b/libsrc/Makefile @@ -31,8 +31,7 @@ TARGETS = apple2 \ sim6502 \ sim65c02 \ supervision\ - telemon24\ - telemon30 + telestrat DRVTYPES = emd \ joy \ diff --git a/libsrc/telemon24/crt0.s b/libsrc/telemon24/crt0.s deleted file mode 100644 index a3c92a360..000000000 --- a/libsrc/telemon24/crt0.s +++ /dev/null @@ -1,101 +0,0 @@ -; -; Startup code for cc65 (Oric version) -; -; By Debrune Jérôme <jede@oric.org> and Ullrich von Bassewitz <uz@cc65.org> -; 2016-03-18, Greg King -; - - .export _exit - .export __STARTUP__ : absolute = 1 ; Mark as startup - - .import initlib, donelib - .import callmain, zerobss - .import __MAIN_START__, __MAIN_SIZE__ - - .include "zeropage.inc" - .include "telemon24.inc" - -; ------------------------------------------------------------------------ -; Place the startup code in a special segment. - -.segment "STARTUP" - - tsx - stx spsave ; Save system stk ptr - -; Save space by putting some of the start-up code in a segment -; that will be re-used. - - jsr init - -; Clear the BSS variables (after the constructors have been run). - - jsr zerobss - -; Push the command-line arguments; and, call main(). - - jsr callmain - -; Call the module destructors. This is also the exit() entry. - -_exit: jsr donelib - -; Restore the system stuff. - - ldx spsave - txs -; lda stsave - ; sta STATUS - -; Copy back the zero-page stuff. - - ldx #zpspace - 1 -L2: lda zpsave,x - sta sp,x - dex - bpl L2 - -; Back to BASIC. - - rts - -; ------------------------------------------------------------------------ -; Put this code in a place that will be re-used by BSS, the heap, -; and the C stack. - -.segment "ONCE" - -; Save the zero-page area that we're about to use. - -init: ldx #zpspace - 1 -L1: lda sp,x - sta zpsave,x - dex - bpl L1 - -; Currently, color isn't supported on the text screen. -; Unprotect screen columns 0 and 1 (where each line's color codes would sit). - - ; lda STATUS - ; sta stsave - ; and #%11011111 - ; sta STATUS - -; Set up the C stack. - - lda #<(__MAIN_START__ + __MAIN_SIZE__) - ldx #>(__MAIN_START__ + __MAIN_SIZE__) - sta sp - stx sp+1 ; Set argument stack ptr - -; Call the module constructors. - - jmp initlib - -; ------------------------------------------------------------------------ - -.segment "INIT" - -spsave: .res 1 -stsave: .res 1 -zpsave: .res zpspace diff --git a/libsrc/telemon24/hires.s b/libsrc/telemon24/hires.s deleted file mode 100644 index 80d67824c..000000000 --- a/libsrc/telemon24/hires.s +++ /dev/null @@ -1,22 +0,0 @@ -; -; Ullrich von Bassewitz, 2003-04-13 -; -; void hires(void); -; -; This function is a hack! -; - - .export _hires - - - .include "telemon24.inc" - - -; can be optimized with a macro -.proc _hires - brk - .byt $1a - rts -.endproc - - diff --git a/libsrc/telemon24/mainargs.s b/libsrc/telemon24/mainargs.s deleted file mode 100644 index d8547e500..000000000 --- a/libsrc/telemon24/mainargs.s +++ /dev/null @@ -1,36 +0,0 @@ -; -; 2003-03-07, Ullrich von Bassewitz -; 2011-01-28, Stefan Haubenthal -; 2014-09-10, Greg King -; -; Set up arguments for main -; - - .constructor initmainargs, 24 - .import __argc, __argv - - .include "telemon24.inc" - .macpack generic - -MAXARGS = 10 ; Maximum number of arguments allowed - - -.segment "ONCE" - -.proc initmainargs - -.endproc - -.segment "INIT" - -term: .res 1 -name: .res FNAME_LEN + 1 -args: .res SCREEN_XSIZE * 2 - 1 - -.data - -; This array has zeroes when initmainargs starts. -; char* argv[MAXARGS+1]={name}; - -argv: .addr name - .res MAXARGS * 2 diff --git a/libsrc/telemon24/print.s b/libsrc/telemon24/print.s deleted file mode 100644 index a135cdd18..000000000 --- a/libsrc/telemon24/print.s +++ /dev/null @@ -1,25 +0,0 @@ -; -; Jede -; -; print (char * str); -; -; This function is a hack! -; - - .export _print - .import popax - .importzp tmp1 - .include "telemon24.inc" - -.proc _print - - jsr popax ; get buf - stx tmp1 - ldy tmp1 - brk - .byte $14 - rts - -.endproc - - diff --git a/libsrc/telemon24/tapehdr.s b/libsrc/telemon24/tapehdr.s deleted file mode 100644 index 9b183e11e..000000000 --- a/libsrc/telemon24/tapehdr.s +++ /dev/null @@ -1,36 +0,0 @@ -; -; Based on code by Debrune Jérôme <jede@oric.org> -; 2016-03-17, Greg King -; - - ; The following symbol is used by the linker config. file - ; to force this module to be included into the output file. - .export __ORIXHDR__:abs = 1 - - ; These symbols, also, come from the configuration file. - .import __AUTORUN__, __PROGFLAG__ - .import __BASHEAD_START__, __MAIN_LAST__ - - -; ------------------------------------------------------------------------ -; Oric cassette-tape header - -.segment "ORIXHDR" - - .byte $01, $00 ; - - .byte "ORI" - - .byte $01 ; version - .byte $00,$00 ; mode - .byte $00,$00 ; cpu type - .byte $00,$00 ; OS - - .byte $00 ; reserved - .byte $00 ; auto - - - .dbyt __BASHEAD_START__ ; Address of start of file - .dbyt __MAIN_LAST__ - 1 ; Address of end of file - .dbyt __BASHEAD_START__ ; Address of start of file - diff --git a/libsrc/telemon24/write.s b/libsrc/telemon24/write.s deleted file mode 100644 index 32bbf617c..000000000 --- a/libsrc/telemon24/write.s +++ /dev/null @@ -1,59 +0,0 @@ -; -; Ullrich von Bassewitz, 2003-04-13 -; -; int write (int fd, const void* buf, int count); -; -; This function is a hack! -; - - .export _write - .import popax - .importzp ptr1, ptr2, ptr3, tmp1 - - .include "telemon24.inc" - -.proc _write - - sta ptr3 - stx ptr3+1 ; save count as result - - eor #$FF - sta ptr2 - txa - eor #$FF - sta ptr2+1 ; Remember -count-1 - - jsr popax ; get buf - sta ptr1 - stx ptr1+1 - jsr popax ; get fd and discard -L1: inc ptr2 - bne L2 - inc ptr2+1 - beq L9 -L2: ldy #0 - lda (ptr1),y - tax - cpx #$0A ; Check for \n - bne L3 - brk - .byt $10 - - ldx #$0D -L3: - brk - .byt $10 - inc ptr1 - bne L1 - inc ptr1+1 - jmp L1 - -; No error, return count - -L9: lda ptr3 - ldx ptr3+1 - rts - -.endproc - - diff --git a/libsrc/telemon30/_close.s b/libsrc/telemon30/_close.s deleted file mode 100644 index 84bee3a1b..000000000 --- a/libsrc/telemon30/_close.s +++ /dev/null @@ -1,17 +0,0 @@ - .export _close - .import addysp,popax - .importzp sp,tmp2,tmp3,tmp1 - - ; int open (const char* name, int flags, ...); /* May take a mode argument */ - .include "telemon30.inc" - .include "errno.inc" - .include "fcntl.inc" - -.proc _close -; Throw away any additional parameters passed through the ellipsis - - BRK_TELEMON XCLOSE ; launch primitive ROM - rts -.endproc - - \ No newline at end of file diff --git a/libsrc/telemon30/_read.s b/libsrc/telemon30/_read.s deleted file mode 100644 index ee822f1fd..000000000 --- a/libsrc/telemon30/_read.s +++ /dev/null @@ -1,41 +0,0 @@ -; -; jede jede@oric.org 2017-01-22 -; - - - .FEATURE c_comments,labels_without_colons,pc_assignment, loose_char_term - .export _read - .import popax - - .include "zeropage.inc" - .include "telemon30.inc" -; int read (int fd, void* buf, unsigned count); - -.proc _read - sta ptr1 ; count - stx ptr1+1 ; count - jsr popax ; get buf - - sta PTR_READ_DEST - stx PTR_READ_DEST+1 - sta ptr2 ; in order to calculate nb of bytes read - stx ptr2+1 ; - - ; jsr popax ; fp pointer don't care in this version - - lda ptr1 ; - ldy ptr1+1 ; - BRK_TELEMON XFREAD ; calls telemon30 routine - ; compute nb of bytes read - lda PTR_READ_DEST+1 - sec - sbc ptr2+1 - tax - lda PTR_READ_DEST - sec - sbc ptr2 - ; Here A and X contains number of bytes read - rts -.endproc - - diff --git a/libsrc/telemon30/_scrsize.s b/libsrc/telemon30/_scrsize.s deleted file mode 100644 index a929f97b1..000000000 --- a/libsrc/telemon30/_scrsize.s +++ /dev/null @@ -1,19 +0,0 @@ -; -; 2003-04-13, Ullrich von Bassewitz -; 2013-07-16, Greg King -; -; Screen size variables -; - - .export screensize - .include "telemon30.inc" - -.proc screensize - - ldx #SCREEN_XSIZE - ldy #SCREEN_YSIZE - rts - -.endproc - - diff --git a/libsrc/telemon30/ch376.s b/libsrc/telemon30/ch376.s deleted file mode 100644 index 460a70052..000000000 --- a/libsrc/telemon30/ch376.s +++ /dev/null @@ -1,366 +0,0 @@ - - ; For XA65 compatibily in the future - .FEATURE c_comments,labels_without_colons,pc_assignment, loose_char_term - .export _ch376_set_file_name - .export _ch376_file_open - .export _ch376_ic_get_version - .export _ch376_reset - .export _ch376_check_exist - .export _ch376_disk_mount - .export _ch376_set_usb_mode - - .export _ch376_file_close - .export _ch376_seek_file - .export _ch376_file_create - .export _ch376_fwrite - ; High level function - - - .import popax - .include "zeropage.inc" - .include "telemon30.inc" -/* - -*/ -; CODE FOR CH376_SET_USB_MODE ************************************************* - -CH376_SET_USB_MODE_CODE_USB_HOST_SOF_PACKAGE_AUTOMATICALLY := $06 - -CH376_USB_INT_SUCCESS := $14 -CH376_USB_INT_CONNECT := $15 -CH376_USB_INT_DISCONNECT := $16 -CH376_USB_INT_BUF_OVER := $17 -CH376_USB_INT_USB_READY := $18 -CH376_USB_INT_DISK_READ := $1D -CH376_USB_INT_DISK_WRITE := $1E -CH376_USB_INT_DISK_ERR := $1F - - -CH376_ERR_OPEN_DIR := $41 -CH376_ERR_MISS_FILE := $42 -CH376_ERR_FOUND_NAME := $43 -CH376_ERR_DISK_DISCON := $82 -CH376_ERR_LARGE_SECTOR := $84 -CH376_ERR_TYPE_ERROR := $92 -CH376_ERR_BPB_ERROR := $A1 -CH376_ERR_DISK_FULL := $B1 -CH376_ERR_FDT_OVER := $B2 -CH376_ERR_FILE_CLOSE := $B4 - - - -CH376_GET_IC_VER := $01 -CH376_SET_BAUDRATE := $02 -CH376_GET_ENTER_SLEEP := $03 -CH376_RESET_ALL := $05 -CH376_CHECK_EXIST := $06 -CH376_GET_FILE_SIZE := $0C - -CH376_SET_USB_MODE := $15 -CH376_GET_STATUS := $22 -CH376_RD_USB_DATA0 := $27 -CH376_CMD_WR_REQ_DATA := $2d -CH376_SET_FILE_NAME := $2F - -CH376_DISK_CONNECT := $30 ; check the disk connection status -CH376_DISK_MOUNT := $31 -CH376_FILE_OPEN := $32 -CH376_FILE_ENUM_GO := $33 -CH376_FILE_CREATE := $34 -CH376_FILE_CLOSE := $36 -CH376_BYTE_LOCATE := $39 -CH376_BYTE_READ := $3A -CH376_BYTE_RD_GO := $3B -CH376_BYTE_WRITE := $3C -CH376_BYTE_WR_GO := $3D -CH376_DISK_CAPACITY := $3E -CH376_DISK_RD_GO := $55 - -.proc _ch376_file_close - lda #CH376_FILE_CLOSE - sta CH376_COMMAND - jsr _ch376_wait_response - rts -.endproc - -.proc _ch376_seek_file - ldx #CH376_BYTE_LOCATE - stx CH376_COMMAND - sta CH376_DATA - sty CH376_DATA - lda #$00 ; Don't manage 32 bits length - sta CH376_DATA - sta CH376_DATA - jsr _ch376_wait_response - rts -.endproc - -; void ch376_set_file_name(char *filename) -.proc _ch376_set_file_name - sta ptr1 - stx ptr1+1 - lda #CH376_SET_FILE_NAME ;$2f - sta CH376_COMMAND - ldy #0 -loop: - lda (ptr1),y ; replace by bufnom - beq end ; we reached 0 value - BRK_TELEMON XMINMA - sta CH376_DATA - iny - cpy #13 ; because we don't manage longfilename shortname =11 - bne loop -end: - sta CH376_DATA - rts -.endproc - -; char _ch376_file_open(); - -.proc _ch376_file_open - lda #CH376_FILE_OPEN ; $32 - sta CH376_COMMAND - jsr _ch376_wait_response - rts -.endproc - - - -.proc _ch376_get_file_size - lda #CH376_GET_FILE_SIZE - sta CH376_COMMAND - lda #$68 - sta CH376_DATA - ; store file length 32 bits - lda CH376_DATA - sta tmp1 - lda CH376_DATA - sta tmp1+1 - lda CH376_DATA - sta tmp2 - lda CH376_DATA - sta tmp2+1 - rts -.endproc - -; void ch376_reset(); - -.proc _ch376_reset - lda #CH376_RESET_ALL ; 5 - sta CH376_COMMAND - ; waiting - ldy #0 - ldx #0 -loop: - nop - inx - bne loop - iny - bne loop - rts -.endproc - -; char ch376_check_exist(char value); - -.proc _ch376_check_exist - sta tmp1 - lda #CH376_CHECK_EXIST ; - sta CH376_COMMAND - lda tmp1 - sta CH376_DATA - lda CH376_DATA - rts -.endproc - -; char ch376_ic_get_version(void) -.proc _ch376_ic_get_version - lda #CH376_GET_IC_VER - sta CH376_COMMAND - ldx #0 - lda CH376_DATA - rts -.endproc - -; void ch376_set_usb_mode(char mode) - -.proc _ch376_set_usb_mode -; CH376_SET_USB_MODE_CODE_USB_HOST_SOF_PACKAGE_AUTOMATICALLY - ldx #CH376_SET_USB_MODE ; $15 - stx CH376_COMMAND - sta CH376_DATA - rts -.endproc - -; void ch376_set_bytes_write(int value); -.proc _ch376_set_bytes_write - ldy #CH376_BYTE_WRITE - sty CH376_COMMAND - sta CH376_DATA - stx CH376_DATA - lda #0 - sta CH376_DATA - sta CH376_DATA - jsr _ch376_wait_response - rts -.endproc - -.proc _ch376_set_bytes_read - ldy #CH376_BYTE_READ - sty CH376_COMMAND - ; Storing 32 bits value - sta CH376_DATA - stx CH376_DATA - lda #0 - sta CH376_DATA - sta CH376_DATA - jsr _ch376_wait_response - rts -.endproc - -; char ch376_disk_mount(); -.proc _ch376_disk_mount - lda #CH376_DISK_MOUNT ; $31 - sta CH376_COMMAND - jsr _ch376_wait_response - ; if we read data value, we have then length of the volume name - ldx #0 - rts -.endproc - - -; char ch376_wait_response(); -.proc _ch376_wait_response -; 1 return 1 if usb controller does not respond -; else A contains answer of the controller - ldy #$ff -loop3: - ldx #$ff ; don't decrease this counter. Because ch376 won't respond if there is a lower value -loop: - lda CH376_COMMAND - and #%10000000 - cmp #128 - bne no_error - dex - bne loop - dey - bne loop3 - ; error is here - rts -no_error: - lda #CH376_GET_STATUS - sta CH376_COMMAND - lda CH376_DATA - rts -.endproc - -.proc _ch376_fread - ; use ptr1 to count bytes - jsr _ch376_set_bytes_read - -continue: - cmp #CH376_USB_INT_DISK_READ ; something to read - beq we_read - cmp #CH376_USB_INT_SUCCESS ; finished - beq finished - ; TODO in A : $ff X: $ff - lda #0 - tax - rts -we_read: - lda #CH376_RD_USB_DATA0 - sta CH376_COMMAND - - lda CH376_DATA ; contains length read - sta tmp2; Number of bytes to read - - ldy #0 -loop: - lda CH376_DATA ; read the data - sta (PTR_READ_DEST),y - - iny - cpy tmp2 - bne loop - tya - clc - adc PTR_READ_DEST - bcc next - inc PTR_READ_DEST+1 -next: - sta PTR_READ_DEST - - lda #CH376_BYTE_RD_GO - sta CH376_COMMAND - jsr _ch376_wait_response - jmp continue -finished: - ; TODO return bytes read - lda tmp1 - ldx tmp1+1 - rts -.endproc - -; void _ch376_fwrite(void *ptr,int number) -.proc _ch376_fwrite - ; use ptr1 to count bytes - sta ptr2 - stx ptr2+1 - - jsr popax - sta PTR_READ_DEST - stx PTR_READ_DEST+1 - - lda ptr2 - ldx ptr2+1 - jsr _ch376_set_bytes_write - ;cmp #CH376_USB_INT_SUCCESS - ;beq finished - ;jsr popax - - ;jsr _ch376_wait_response - -continue: - cmp #CH376_USB_INT_DISK_WRITE ; something to read - beq we_read - cmp #CH376_USB_INT_SUCCESS ; finished - beq finished - ; TODO in A : $ff X: $ff - lda #0 - tax - rts -we_read: - lda #CH376_CMD_WR_REQ_DATA - sta CH376_COMMAND - - lda CH376_DATA ; contains length read - sta tmp2; Number of bytes to read - - - ;ldy #0 -loop: - ;lda (PTR_READ_DEST),y - lda #65 - sta CH376_DATA ; read the data - dec tmp2 - bne loop - - - lda #CH376_BYTE_WR_GO - sta CH376_COMMAND - jsr _ch376_wait_response - jmp continue -finished: - ; TODO return bytes read - lda tmp1 - ;lda #<8000 - ldx tmp1+1 - ;ldx #>8000 - rts -.endproc - -.proc _ch376_file_create - lda #CH376_FILE_CREATE - sta CH376_COMMAND - jsr _ch376_wait_response - rts -.endproc \ No newline at end of file diff --git a/libsrc/telemon30/ctype.s b/libsrc/telemon30/ctype.s deleted file mode 100644 index 79edafbb2..000000000 --- a/libsrc/telemon30/ctype.s +++ /dev/null @@ -1,299 +0,0 @@ -; -; Ullrich von Bassewitz, 2003-04-13 -; -; Character specification table. -; - -; The tables are readonly, put them into the rodata segment - -.rodata - -; The following 256 byte wide table specifies attributes for the isxxx type -; of functions. Doing it by a table means some overhead in space, but it -; has major advantages: -; -; * It is fast. If it were'nt for the slow parameter passing of cc65, one -; could even define macros for the isxxx functions (this is usually -; done on other platforms). -; -; * It is highly portable. The only unportable part is the table itself, -; all real code goes into the common library. -; -; * We save some code in the isxxx functions. -; -; -; Bit assignments: -; -; 0 - Lower case char -; 1 - Upper case char -; 2 - Numeric digit -; 3 - Hex digit (both, lower and upper) -; 4 - Control character -; 5 - The space character itself -; 6 - Other whitespace (that is: '\f', '\n', '\r', '\t' and '\v') -; 7 - Space or tab character - - .export __ctype - -__ctype: - .byte $10 ; 0/00 ___ctrl_@___ - .byte $10 ; 1/01 ___ctrl_A___ - .byte $10 ; 2/02 ___ctrl_B___ - .byte $10 ; 3/03 ___ctrl_C___ - .byte $10 ; 4/04 ___ctrl_D___ - .byte $10 ; 5/05 ___ctrl_E___ - .byte $10 ; 6/06 ___ctrl_F___ - .byte $10 ; 7/07 ___ctrl_G___ - .byte $10 ; 8/08 ___ctrl_H___ - .byte $D0 ; 9/09 ___ctrl_I___ - .byte $50 ; 10/0a ___ctrl_J___ - .byte $50 ; 11/0b ___ctrl_K___ - .byte $50 ; 12/0c ___ctrl_L___ - .byte $50 ; 13/0d ___ctrl_M___ - .byte $10 ; 14/0e ___ctrl_N___ - .byte $10 ; 15/0f ___ctrl_O___ - .byte $10 ; 16/10 ___ctrl_P___ - .byte $10 ; 17/11 ___ctrl_Q___ - .byte $10 ; 18/12 ___ctrl_R___ - .byte $10 ; 19/13 ___ctrl_S___ - .byte $10 ; 20/14 ___ctrl_T___ - .byte $10 ; 21/15 ___ctrl_U___ - .byte $10 ; 22/16 ___ctrl_V___ - .byte $10 ; 23/17 ___ctrl_W___ - .byte $10 ; 24/18 ___ctrl_X___ - .byte $10 ; 25/19 ___ctrl_Y___ - .byte $10 ; 26/1a ___ctrl_Z___ - .byte $10 ; 27/1b ___ctrl_[___ - .byte $10 ; 28/1c ___ctrl_\___ - .byte $10 ; 29/1d ___ctrl_]___ - .byte $10 ; 30/1e ___ctrl_^___ - .byte $10 ; 31/1f ___ctrl_____ - .byte $A0 ; 32/20 ___SPACE___ - .byte $00 ; 33/21 _____!_____ - .byte $00 ; 34/22 _____"_____ - .byte $00 ; 35/23 _____#_____ - .byte $00 ; 36/24 _____$_____ - .byte $00 ; 37/25 _____%_____ - .byte $00 ; 38/26 _____&_____ - .byte $00 ; 39/27 _____'_____ - .byte $00 ; 40/28 _____(_____ - .byte $00 ; 41/29 _____)_____ - .byte $00 ; 42/2a _____*_____ - .byte $00 ; 43/2b _____+_____ - .byte $00 ; 44/2c _____,_____ - .byte $00 ; 45/2d _____-_____ - .byte $00 ; 46/2e _____._____ - .byte $00 ; 47/2f _____/_____ - .byte $0C ; 48/30 _____0_____ - .byte $0C ; 49/31 _____1_____ - .byte $0C ; 50/32 _____2_____ - .byte $0C ; 51/33 _____3_____ - .byte $0C ; 52/34 _____4_____ - .byte $0C ; 53/35 _____5_____ - .byte $0C ; 54/36 _____6_____ - .byte $0C ; 55/37 _____7_____ - .byte $0C ; 56/38 _____8_____ - .byte $0C ; 57/39 _____9_____ - .byte $00 ; 58/3a _____:_____ - .byte $00 ; 59/3b _____;_____ - .byte $00 ; 60/3c _____<_____ - .byte $00 ; 61/3d _____=_____ - .byte $00 ; 62/3e _____>_____ - .byte $00 ; 63/3f _____?_____ - - .byte $00 ; 64/40 _____@_____ - .byte $0A ; 65/41 _____A_____ - .byte $0A ; 66/42 _____B_____ - .byte $0A ; 67/43 _____C_____ - .byte $0A ; 68/44 _____D_____ - .byte $0A ; 69/45 _____E_____ - .byte $0A ; 70/46 _____F_____ - .byte $02 ; 71/47 _____G_____ - .byte $02 ; 72/48 _____H_____ - .byte $02 ; 73/49 _____I_____ - .byte $02 ; 74/4a _____J_____ - .byte $02 ; 75/4b _____K_____ - .byte $02 ; 76/4c _____L_____ - .byte $02 ; 77/4d _____M_____ - .byte $02 ; 78/4e _____N_____ - .byte $02 ; 79/4f _____O_____ - .byte $02 ; 80/50 _____P_____ - .byte $02 ; 81/51 _____Q_____ - .byte $02 ; 82/52 _____R_____ - .byte $02 ; 83/53 _____S_____ - .byte $02 ; 84/54 _____T_____ - .byte $02 ; 85/55 _____U_____ - .byte $02 ; 86/56 _____V_____ - .byte $02 ; 87/57 _____W_____ - .byte $02 ; 88/58 _____X_____ - .byte $02 ; 89/59 _____Y_____ - .byte $02 ; 90/5a _____Z_____ - .byte $00 ; 91/5b _____[_____ - .byte $00 ; 92/5c _____\_____ - .byte $00 ; 93/5d _____]_____ - .byte $00 ; 94/5e _____^_____ - .byte $00 ; 95/5f _UNDERLINE_ - .byte $00 ; 96/60 ___grave___ - .byte $09 ; 97/61 _____a_____ - .byte $09 ; 98/62 _____b_____ - .byte $09 ; 99/63 _____c_____ - .byte $09 ; 100/64 _____d_____ - .byte $09 ; 101/65 _____e_____ - .byte $09 ; 102/66 _____f_____ - .byte $01 ; 103/67 _____g_____ - .byte $01 ; 104/68 _____h_____ - .byte $01 ; 105/69 _____i_____ - .byte $01 ; 106/6a _____j_____ - .byte $01 ; 107/6b _____k_____ - .byte $01 ; 108/6c _____l_____ - .byte $01 ; 109/6d _____m_____ - .byte $01 ; 110/6e _____n_____ - .byte $01 ; 111/6f _____o_____ - .byte $01 ; 112/70 _____p_____ - .byte $01 ; 113/71 _____q_____ - .byte $01 ; 114/72 _____r_____ - .byte $01 ; 115/73 _____s_____ - .byte $01 ; 116/74 _____t_____ - .byte $01 ; 117/75 _____u_____ - .byte $01 ; 118/76 _____v_____ - .byte $01 ; 119/77 _____w_____ - .byte $01 ; 120/78 _____x_____ - .byte $01 ; 121/79 _____y_____ - .byte $01 ; 122/7a _____z_____ - .byte $00 ; 123/7b _____{_____ - .byte $00 ; 124/7c _____|_____ - .byte $00 ; 125/7d _____}_____ - .byte $00 ; 126/7e _____~_____ - .byte $40 ; 127/7f ____DEL____ - - .byte $00 ; 128/80 ___________ - .byte $00 ; 129/81 ___________ - .byte $00 ; 130/82 ___________ - .byte $00 ; 131/83 ___________ - .byte $00 ; 132/84 ___________ - .byte $00 ; 133/85 ___________ - .byte $00 ; 134/86 ___________ - .byte $00 ; 135/87 ___________ - .byte $00 ; 136/88 ___________ - .byte $00 ; 137/89 ___________ - .byte $00 ; 138/8a ___________ - .byte $00 ; 139/8b ___________ - .byte $00 ; 140/8c ___________ - .byte $00 ; 141/8d ___________ - .byte $00 ; 142/8e ___________ - .byte $00 ; 143/8f ___________ - .byte $00 ; 144/90 ___________ - .byte $00 ; 145/91 ___________ - .byte $00 ; 146/92 ___________ - .byte $10 ; 147/93 ___________ - .byte $00 ; 148/94 ___________ - .byte $00 ; 149/95 ___________ - .byte $00 ; 150/96 ___________ - .byte $00 ; 151/97 ___________ - .byte $00 ; 152/98 ___________ - .byte $00 ; 153/99 ___________ - .byte $00 ; 154/9a ___________ - .byte $00 ; 155/9b ___________ - .byte $00 ; 156/9c ___________ - .byte $00 ; 157/9d ___________ - .byte $00 ; 158/9e ___________ - .byte $00 ; 159/9f ___________ - - .byte $00 ; 160/a0 ___________ - .byte $00 ; 161/a1 ___________ - .byte $00 ; 162/a2 ___________ - .byte $00 ; 163/a3 ___________ - .byte $00 ; 164/a4 ___________ - .byte $00 ; 165/a5 ___________ - .byte $00 ; 166/a6 ___________ - .byte $00 ; 167/a7 ___________ - .byte $00 ; 168/a8 ___________ - .byte $00 ; 169/a9 ___________ - .byte $00 ; 170/aa ___________ - .byte $00 ; 171/ab ___________ - .byte $00 ; 172/ac ___________ - .byte $00 ; 173/ad ___________ - .byte $00 ; 174/ae ___________ - .byte $00 ; 175/af ___________ - .byte $00 ; 176/b0 ___________ - .byte $00 ; 177/b1 ___________ - .byte $00 ; 178/b2 ___________ - .byte $00 ; 179/b3 ___________ - .byte $00 ; 180/b4 ___________ - .byte $00 ; 181/b5 ___________ - .byte $00 ; 182/b6 ___________ - .byte $00 ; 183/b7 ___________ - .byte $00 ; 184/b8 ___________ - .byte $00 ; 185/b9 ___________ - .byte $00 ; 186/ba ___________ - .byte $00 ; 187/bb ___________ - .byte $00 ; 188/bc ___________ - .byte $00 ; 189/bd ___________ - .byte $00 ; 190/be ___________ - .byte $00 ; 191/bf ___________ - - .byte $02 ; 192/c0 ___________ - .byte $02 ; 193/c1 ___________ - .byte $02 ; 194/c2 ___________ - .byte $02 ; 195/c3 ___________ - .byte $02 ; 196/c4 ___________ - .byte $02 ; 197/c5 ___________ - .byte $02 ; 198/c6 ___________ - .byte $02 ; 199/c7 ___________ - .byte $02 ; 200/c8 ___________ - .byte $02 ; 201/c9 ___________ - .byte $02 ; 202/ca ___________ - .byte $02 ; 203/cb ___________ - .byte $02 ; 204/cc ___________ - .byte $02 ; 205/cd ___________ - .byte $02 ; 206/ce ___________ - .byte $02 ; 207/cf ___________ - .byte $02 ; 208/d0 ___________ - .byte $02 ; 209/d1 ___________ - .byte $02 ; 210/d2 ___________ - .byte $02 ; 211/d3 ___________ - .byte $02 ; 212/d4 ___________ - .byte $02 ; 213/d5 ___________ - .byte $02 ; 214/d6 ___________ - .byte $02 ; 215/d7 ___________ - .byte $02 ; 216/d8 ___________ - .byte $02 ; 217/d9 ___________ - .byte $02 ; 218/da ___________ - .byte $02 ; 219/db ___________ - .byte $02 ; 220/dc ___________ - .byte $02 ; 221/dd ___________ - .byte $02 ; 222/de ___________ - .byte $00 ; 223/df ___________ - .byte $01 ; 224/e0 ___________ - .byte $01 ; 225/e1 ___________ - .byte $01 ; 226/e2 ___________ - .byte $01 ; 227/e3 ___________ - .byte $01 ; 228/e4 ___________ - .byte $01 ; 229/e5 ___________ - .byte $01 ; 230/e6 ___________ - .byte $01 ; 231/e7 ___________ - .byte $01 ; 232/e8 ___________ - .byte $01 ; 233/e9 ___________ - .byte $01 ; 234/ea ___________ - .byte $01 ; 235/eb ___________ - .byte $01 ; 236/ec ___________ - .byte $01 ; 237/ed ___________ - .byte $01 ; 238/ee ___________ - .byte $01 ; 239/ef ___________ - .byte $01 ; 240/f0 ___________ - .byte $01 ; 241/f1 ___________ - .byte $01 ; 242/f2 ___________ - .byte $01 ; 243/f3 ___________ - .byte $01 ; 244/f4 ___________ - .byte $01 ; 245/f5 ___________ - .byte $01 ; 246/f6 ___________ - .byte $01 ; 247/f7 ___________ - .byte $01 ; 248/f8 ___________ - .byte $01 ; 249/f9 ___________ - .byte $01 ; 250/fa ___________ - .byte $01 ; 251/fb ___________ - .byte $01 ; 252/fc ___________ - .byte $01 ; 253/fd ___________ - .byte $01 ; 254/fe ___________ - .byte $00 ; 255/ff ___________ - diff --git a/libsrc/telemon30/graphics.s b/libsrc/telemon30/graphics.s deleted file mode 100644 index 4f2b09162..000000000 --- a/libsrc/telemon30/graphics.s +++ /dev/null @@ -1,54 +0,0 @@ - .export _paper,_hires,_text,_circle,_curset, _switchOffCursor - .importzp sp,tmp2,tmp3,tmp1 - .import popa - .include "telemon30.inc" - -.proc _paper - ldx #0 ; First window - ; A contains the paper - BRK_TELEMON XPAPER - rts -.endproc - -; XINK is bugged, it corrupt memory : removing from export -.proc _ink - ldx #0 ; First window - ; A contains the ink - BRK_TELEMON XINK - rts -.endproc - -; can be optimized with a macro -.proc _hires - BRK_TELEMON XHIRES - rts -.endproc - -.proc _text - BRK_TELEMON XTEXT - rts -.endproc - -.proc _curset - jsr popa ; Pixel - jsr popa - sta HRSX - jsr popa - sta HRSY - BRK_TELEMON XCURSE - rts -.endproc - -.proc _circle - sta HRS1 - BRK_TELEMON XCIRCL - rts -.endproc - -.proc _switchOffCursor - ldx #0 - BRK_TELEMON XCOSCR - rts -.endproc - - diff --git a/libsrc/telemon30/keyboard.s b/libsrc/telemon30/keyboard.s deleted file mode 100644 index 974f841e6..000000000 --- a/libsrc/telemon30/keyboard.s +++ /dev/null @@ -1,13 +0,0 @@ - .export _key - .importzp sp,tmp2,tmp3,tmp1 - - .include "telemon30.inc" - - -; char key(void); - -.proc _key - BRK_TELEMON XRDW0 ; read keyboard - rts -.endproc - diff --git a/libsrc/telemon30/oserrlist.s b/libsrc/telemon30/oserrlist.s deleted file mode 100644 index 8ec41de6d..000000000 --- a/libsrc/telemon30/oserrlist.s +++ /dev/null @@ -1,75 +0,0 @@ -; -; Stefan Haubenthal, 2004-05-25 -; Ullrich von Bassewitz, 18.07.2002 -; -; Defines the platform specific error list. -; -; The table is built as a list of entries -; -; .byte entrylen -; .byte errorcode -; .asciiz errormsg -; -; and terminated by an entry with length zero that is returned if the -; error code could not be found. -; - - .export __sys_oserrlist - -;---------------------------------------------------------------------------- -; Macros used to generate the list (may get moved to an include file?) - -; Regular entry -.macro sys_oserr_entry code, msg - .local Start, End -Start: .byte End - Start - .byte code - .asciiz msg -End: -.endmacro - -; Sentinel entry -.macro sys_oserr_sentinel msg - .byte 0 ; Length is always zero - .byte 0 ; Code is unused - .asciiz msg -.endmacro - -;---------------------------------------------------------------------------- -; The error message table - -.rodata - -__sys_oserrlist: - sys_oserr_entry 1, "File not found" - sys_oserr_entry 2, "Invalid command end" - sys_oserr_entry 3, "No drive number" - sys_oserr_entry 4, "Bad drive number" - sys_oserr_entry 5, "Invalid filename" - sys_oserr_entry 6, "fderr=(error number)" - sys_oserr_entry 7, "Illegal attribute" - sys_oserr_entry 8, "Wildcard(s) not allowed" - sys_oserr_entry 9, "File already exists" - sys_oserr_entry 10, "Insufficient disc space" - sys_oserr_entry 11, "File open" - sys_oserr_entry 12, "Illegal quantity" - sys_oserr_entry 13, "End address missing" - sys_oserr_entry 14, "Start address > end address" - sys_oserr_entry 15, "Missing 'to'" - sys_oserr_entry 16, "Renamed file not on same disc" - sys_oserr_entry 17, "Unknown array" - sys_oserr_entry 18, "Target drive not source drive" - sys_oserr_entry 19, "Destination not specified" - sys_oserr_entry 20, "Cannot merge and overwrite" - sys_oserr_entry 21, "Single target file illegal" - sys_oserr_entry 22, "Syntax" - sys_oserr_entry 23, "Filename missing" - sys_oserr_entry 24, "Source file missing" - sys_oserr_entry 25, "Type mismatch" - sys_oserr_entry 26, "Disc write-protected" - sys_oserr_entry 27, "Incompatible drives" - sys_oserr_entry 28, "File not open" - sys_oserr_entry 29, "File end" - sys_oserr_sentinel "Unknown error" - - diff --git a/libsrc/telemon30/oserror.s b/libsrc/telemon30/oserror.s deleted file mode 100644 index 37c9bd7fc..000000000 --- a/libsrc/telemon30/oserror.s +++ /dev/null @@ -1,17 +0,0 @@ -; -; Stefan Haubenthal, 2011-04-18 -; -; int __fastcall__ _osmaperrno (unsigned char oserror); -; /* Map a system specific error into a system independent code */ -; - - .include "errno.inc" - .export __osmaperrno - -.proc __osmaperrno - - lda #<EUNKNOWN - ldx #>EUNKNOWN - rts - -.endproc diff --git a/libsrc/telemon30/print.s b/libsrc/telemon30/print.s deleted file mode 100644 index 56c513fd6..000000000 --- a/libsrc/telemon30/print.s +++ /dev/null @@ -1,21 +0,0 @@ -; -; Jede -; -; print (char * str); -; -; This function is a hack! -; - - .export _print - .import popax - .importzp tmp1 - .include "telemon30.inc" - -.proc _print - stx tmp1 - ldy tmp1 - BRK_TELEMON XWSTR0 - rts -.endproc - - diff --git a/libsrc/telemon30/sound.s b/libsrc/telemon30/sound.s deleted file mode 100644 index 2df18f4a0..000000000 --- a/libsrc/telemon30/sound.s +++ /dev/null @@ -1,45 +0,0 @@ - .export _kbdclick1,_oups,_ping,_explode,_shoot,_zap - .include "telemon30.inc" - -.proc _kbdclick1 - LDX #<sound_bip_keyboard - LDY #>sound_bip_keyboard - BRK_TELEMON XSONPS - rts -sound_bip_keyboard: - .byte $1f,$00,$00,$00,$00,$00,$00,$3e,$10,$00,$00,$1f,$00,$00 -.endproc - -.proc _explode - BRK_TELEMON XEXPLO - rts -.endproc - -.proc _oups - BRK_TELEMON XOUPS - rts -.endproc - -.proc _ping - BRK_TELEMON XPING - rts -.endproc - -.proc _shoot - BRK_TELEMON XSHOOT - rts -.endproc - -.proc _zap - BRK_TELEMON XZAP - rts -.endproc - - - -; XPLAY := $43 -; XSOUND := $44 -; XMUSIC := $45 - - - diff --git a/libsrc/telemon30/sysuname.s b/libsrc/telemon30/sysuname.s deleted file mode 100644 index 51af1d8fe..000000000 --- a/libsrc/telemon30/sysuname.s +++ /dev/null @@ -1,46 +0,0 @@ -; -; Ullrich von Bassewitz, 2003-08-12 -; -; unsigned char __fastcall__ _sysuname (struct utsname* buf); -; - - .export __sysuname, utsdata - - .import utscopy - - __sysuname = utscopy - -;-------------------------------------------------------------------------- -; Data. We define a fixed utsname struct here and just copy it. - -.rodata - -utsdata: - ; sysname - .asciiz "cc65" - - ; nodename - .asciiz "" - - ; release - .byte ((.VERSION >> 8) & $0F) + '0' - .byte '.' - .if ((.VERSION >> 4) & $0F) > 9 - .byte ((.VERSION >> 4) & $0F) / 10 + '0' - .byte ((.VERSION >> 4) & $0F) .MOD 10 + '0' - .else - .byte ((.VERSION >> 4) & $0F) + '0' - .endif - .byte $00 - - ; version - .if (.VERSION & $0F) > 9 - .byte (.VERSION & $0F) / 10 + '0' - .byte (.VERSION & $0F) .MOD 10 + '0' - .else - .byte (.VERSION & $0F) + '0' - .endif - .byte $00 - - ; machine - .asciiz "Oric Telestrat" diff --git a/libsrc/telestrat/ch376.s b/libsrc/telestrat/ch376.s new file mode 100644 index 000000000..fbfa16017 --- /dev/null +++ b/libsrc/telestrat/ch376.s @@ -0,0 +1,344 @@ + +; jede jede@oric.org 2017-01-22 + + ; For XA65 compatibily in the future + .FEATURE c_comments,labels_without_colons,pc_assignment, loose_char_term + .export _ch376_set_file_name + .export _ch376_file_open + .export _ch376_ic_get_version + .export _ch376_reset + .export _ch376_check_exist + .export _ch376_disk_mount + .export _ch376_set_usb_mode + .export _ch376_file_close + .export _ch376_seek_file + .export _ch376_file_create + .export _ch376_fwrite + + .import popax + .include "zeropage.inc" + .include "telestrat.inc" + + + + + +CH376_SET_USB_MODE_CODE_USB_HOST_SOF_PACKAGE_AUTOMATICALLY = $06 + +CH376_USB_INT_SUCCESS = $14 +CH376_USB_INT_CONNECT = $15 +CH376_USB_INT_DISCONNECT = $16 +CH376_USB_INT_BUF_OVER = $17 +CH376_USB_INT_USB_READY = $18 +CH376_USB_INT_DISK_READ = $1D +CH376_USB_INT_DISK_WRITE = $1E +CH376_USB_INT_DISK_ERR = $1F + + +CH376_ERR_OPEN_DIR = $41 +CH376_ERR_MISS_FILE = $42 +CH376_ERR_FOUND_NAME = $43 +CH376_ERR_DISK_DISCON = $82 +CH376_ERR_LARGE_SECTOR = $84 +CH376_ERR_TYPE_ERROR = $92 +CH376_ERR_BPB_ERROR = $A1 +CH376_ERR_DISK_FULL = $B1 +CH376_ERR_FDT_OVER = $B2 +CH376_ERR_FILE_CLOSE = $B4 + +CH376_GET_IC_VER = $01 +CH376_SET_BAUDRATE = $02 +CH376_GET_ENTER_SLEEP = $03 +CH376_RESET_ALL = $05 +CH376_CHECK_EXIST = $06 +CH376_GET_FILE_SIZE = $0C + +CH376_SET_USB_MODE = $15 +CH376_GET_STATUS = $22 +CH376_RD_USB_DATA0 = $27 +CH376_CMD_WR_REQ_DATA = $2D +CH376_SET_FILE_NAME = $2F + +CH376_DISK_CONNECT = $30 ; check the disk connection status +CH376_DISK_MOUNT = $31 +CH376_FILE_OPEN = $32 +CH376_FILE_ENUM_GO = $33 +CH376_FILE_CREATE = $34 +CH376_FILE_CLOSE = $36 +CH376_BYTE_LOCATE = $39 +CH376_BYTE_READ = $3A +CH376_BYTE_RD_GO = $3B +CH376_BYTE_WRITE = $3C +CH376_BYTE_WR_GO = $3D +CH376_DISK_CAPACITY = $3E +CH376_DISK_RD_GO = $55 + +.proc _ch376_file_close + lda #CH376_FILE_CLOSE + sta CH376_COMMAND + jsr _ch376_wait_response + rts +.endproc + +.proc _ch376_seek_file + ldx #CH376_BYTE_LOCATE + stx CH376_COMMAND + sta CH376_DATA + sty CH376_DATA + lda #$00 ; Don't manage 32 bits length + sta CH376_DATA + sta CH376_DATA + jsr _ch376_wait_response + rts +.endproc + +; void ch376_set_file_name(char *filename) +.proc _ch376_set_file_name + sta ptr1 + stx ptr1+1 + lda #CH376_SET_FILE_NAME ;$2f + sta CH376_COMMAND + ldy #0 +loop: + lda (ptr1),y ; replace by bufnom + beq end ; we reached 0 value + BRK_TELEMON XMINMA + sta CH376_DATA + iny + cpy #13 ; because we don't manage longfilename shortname =11 + bne loop +end: + sta CH376_DATA + rts +.endproc + +; char _ch376_file_open(); +.proc _ch376_file_open + lda #CH376_FILE_OPEN ; $32 + sta CH376_COMMAND + jsr _ch376_wait_response + rts +.endproc + +.proc _ch376_get_file_size + lda #CH376_GET_FILE_SIZE + sta CH376_COMMAND + lda #$68 + sta CH376_DATA + ; store file length 32 bits + lda CH376_DATA + sta tmp1 + lda CH376_DATA + sta tmp1+1 + lda CH376_DATA + sta tmp2 + lda CH376_DATA + sta tmp2+1 + rts +.endproc + +; void ch376_reset(); +.proc _ch376_reset + lda #CH376_RESET_ALL ; 5 + sta CH376_COMMAND + ; waiting + ldy #0 + ldx #0 +loop: + nop + inx + bne loop + iny + bne loop + rts +.endproc + +; char ch376_check_exist(char value); + +.proc _ch376_check_exist + sta tmp1 + lda #CH376_CHECK_EXIST ; + sta CH376_COMMAND + lda tmp1 + sta CH376_DATA + lda CH376_DATA + rts +.endproc + +; char ch376_ic_get_version(void) +.proc _ch376_ic_get_version + lda #CH376_GET_IC_VER + sta CH376_COMMAND + ldx #0 + lda CH376_DATA + rts +.endproc + +; void ch376_set_usb_mode(char mode) +.proc _ch376_set_usb_mode + ldx #CH376_SET_USB_MODE ; $15 + stx CH376_COMMAND + sta CH376_DATA + rts +.endproc + +; void ch376_set_bytes_write(int value); +.proc _ch376_set_bytes_write + ldy #CH376_BYTE_WRITE + sty CH376_COMMAND + sta CH376_DATA + stx CH376_DATA + lda #0 + sta CH376_DATA + sta CH376_DATA + jsr _ch376_wait_response + rts +.endproc + +.proc _ch376_set_bytes_read + ldy #CH376_BYTE_READ + sty CH376_COMMAND + ; Storing 32 bits value + sta CH376_DATA + stx CH376_DATA + lda #0 + sta CH376_DATA + sta CH376_DATA + jsr _ch376_wait_response + rts +.endproc + +; char ch376_disk_mount(); +.proc _ch376_disk_mount + lda #CH376_DISK_MOUNT ; $31 + sta CH376_COMMAND + jsr _ch376_wait_response + ; if we read data value, we have then length of the volume name + ldx #0 + rts +.endproc + + +; char ch376_wait_response(); +.proc _ch376_wait_response +; return 1 if usb controller does not respond +; else A contains answer of the controller + ldy #$FF ; We have to wait 35 ms, but well, this loop is broken when controler is OK +loop3: + ldx #$FF ; don't decrease this counter. Because ch376 won't respond if there is a lower value +loop: + lda CH376_COMMAND + and #%10000000 + cmp #128 + bne no_error + dex + bne loop + dey + bne loop3 + ; error is here + rts +no_error: + lda #CH376_GET_STATUS + sta CH376_COMMAND + lda CH376_DATA + rts +.endproc + +.proc _ch376_fread + ; use ptr1 to count bytes + jsr _ch376_set_bytes_read +continue: + cmp #CH376_USB_INT_DISK_READ ; something to read + beq we_read + cmp #CH376_USB_INT_SUCCESS ; finished + beq finished + ; TODO in A : $ff X: $ff + lda #0 + tax + rts +we_read: + lda #CH376_RD_USB_DATA0 + sta CH376_COMMAND + + lda CH376_DATA ; contains length read + sta tmp2; Number of bytes to read + + ldy #0 +loop: + lda CH376_DATA ; read the data + sta (PTR_READ_DEST),y + iny + cpy tmp2 + bne loop + tya + clc + adc PTR_READ_DEST + bcc next + inc PTR_READ_DEST+1 +next: + sta PTR_READ_DEST + + lda #CH376_BYTE_RD_GO + sta CH376_COMMAND + jsr _ch376_wait_response + jmp continue +finished: + ; TODO return bytes read + lda tmp1 + ldx tmp1+1 + rts +.endproc + +; void _ch376_fwrite(void *ptr,int number) +.proc _ch376_fwrite + ; use ptr1 to count bytes + sta ptr2 + stx ptr2+1 + + jsr popax + sta PTR_READ_DEST + stx PTR_READ_DEST+1 + + lda ptr2 + ldx ptr2+1 + jsr _ch376_set_bytes_write +continue: + cmp #CH376_USB_INT_DISK_WRITE ; something to read + beq we_read + cmp #CH376_USB_INT_SUCCESS ; finished + beq finished + + lda #0 + tax + rts +we_read: + lda #CH376_CMD_WR_REQ_DATA + sta CH376_COMMAND + + lda CH376_DATA ; contains length read + sta tmp2; Number of bytes to read + + ldy #0 +loop: + lda (PTR_READ_DEST),y + sta CH376_DATA ; read the data + dec tmp2 + bne loop + + + lda #CH376_BYTE_WR_GO + sta CH376_COMMAND + jsr _ch376_wait_response + jmp continue +finished: + lda tmp1 + ldx tmp1+1 + rts +.endproc + +.proc _ch376_file_create + lda #CH376_FILE_CREATE + sta CH376_COMMAND + jsr _ch376_wait_response + rts +.endproc diff --git a/libsrc/telestrat/close.s b/libsrc/telestrat/close.s new file mode 100644 index 000000000..881d0897f --- /dev/null +++ b/libsrc/telestrat/close.s @@ -0,0 +1,18 @@ +; jede jede@oric.org 2017-01-22 + + .export _close + + .import addysp,popax + + .include "zeropage.inc" + .include "telestrat.inc" + .include "errno.inc" + .include "fcntl.inc" + +; int open (const char* name, int flags, ...); /* May take a mode argument */ +.proc _close + BRK_TELEMON XCLOSE ; launch primitive ROM + rts +.endproc + + \ No newline at end of file diff --git a/libsrc/telemon30/crt0.s b/libsrc/telestrat/crt0.s similarity index 85% rename from libsrc/telemon30/crt0.s rename to libsrc/telestrat/crt0.s index 72bad5f24..59b1ea642 100644 --- a/libsrc/telemon30/crt0.s +++ b/libsrc/telestrat/crt0.s @@ -2,7 +2,6 @@ ; Startup code for cc65 (Oric version) ; ; By Debrune Jérôme <jede@oric.org> and Ullrich von Bassewitz <uz@cc65.org> -; 2016-03-18, Greg King ; .export _exit @@ -13,7 +12,7 @@ .import __MAIN_START__, __MAIN_SIZE__ .include "zeropage.inc" - .include "telemon30.inc" + .include "telestrat.inc" ; ------------------------------------------------------------------------ ; Place the startup code in a special segment. @@ -44,8 +43,6 @@ _exit: jsr donelib ldx spsave txs -; lda stsave - ; sta STATUS ; Copy back the zero-page stuff. @@ -73,13 +70,6 @@ L1: lda sp,x dex bpl L1 -; Currently, color isn't supported on the text screen. -; Unprotect screen columns 0 and 1 (where each line's color codes would sit). - - ; lda STATUS - ; sta stsave - ; and #%11011111 - ; sta STATUS ; Set up the C stack. diff --git a/libsrc/telemon24/ctype.s b/libsrc/telestrat/ctype.s similarity index 100% rename from libsrc/telemon24/ctype.s rename to libsrc/telestrat/ctype.s diff --git a/libsrc/telestrat/graphics.s b/libsrc/telestrat/graphics.s new file mode 100644 index 000000000..9984036bb --- /dev/null +++ b/libsrc/telestrat/graphics.s @@ -0,0 +1,58 @@ +; jede jede@oric.org 2017-01-22 + + .export _paper,_hires,_text,_circle,_curset, _switchOffCursor + + .include "zeropage.inc" + .include "telestrat.inc" + .import popa + + +.proc _paper + ldx #0 ; First window + ; A contains the paper + BRK_TELEMON XPAPER + rts +.endproc + +; XINK is bugged, it corrupt memory : removing from export +.proc _ink + ldx #0 ; First window + ; A contains the ink + BRK_TELEMON XINK + rts +.endproc + +; can be optimized with a macro +.proc _hires + BRK_TELEMON XHIRES + rts +.endproc + +.proc _text + BRK_TELEMON XTEXT + rts +.endproc + +.proc _curset + jsr popa ; Pixel + jsr popa + sta HRSX + jsr popa + sta HRSY + BRK_TELEMON XCURSE + rts +.endproc + +.proc _circle + sta HRS1 + BRK_TELEMON XCIRCL + rts +.endproc + +.proc _switchOffCursor + ldx #0 + BRK_TELEMON XCOSCR + rts +.endproc + + diff --git a/libsrc/telestrat/keyboard.s b/libsrc/telestrat/keyboard.s new file mode 100644 index 000000000..7069d1003 --- /dev/null +++ b/libsrc/telestrat/keyboard.s @@ -0,0 +1,14 @@ +; jede jede@oric.org 2017-01-22 + + .export _key + + .include "zeropage.inc" + .include "telestrat.inc" + +; char key(void); + +.proc _key + BRK_TELEMON XRDW0 ; read keyboard + rts +.endproc + diff --git a/libsrc/telemon30/mainargs.s b/libsrc/telestrat/mainargs.s similarity index 90% rename from libsrc/telemon30/mainargs.s rename to libsrc/telestrat/mainargs.s index 452d0d6d6..b41e2a96d 100644 --- a/libsrc/telemon30/mainargs.s +++ b/libsrc/telestrat/mainargs.s @@ -9,7 +9,7 @@ .constructor initmainargs, 24 .import __argc, __argv .import ptr1 - .include "telemon30.inc" + .include "telestrat.inc" .macpack generic MAXARGS = 10 ; Maximum number of arguments allowed @@ -23,8 +23,6 @@ MAXARGS = 10 ; Maximum number of arguments allowed initmainargs: ldx #0 ; Limit the length - ; lda #0 ; The terminating NUL character - ; beq L1 ; Branch always L0: lda BUFEDT,x beq L3 cmp #' ' @@ -40,9 +38,6 @@ L3: sta name,x inc __argc ; argc always is equal to, at least, 1 - - - ldy #1 * 2 ; Point to second argv slot @@ -52,31 +47,24 @@ next: lda BUFEDT,x cmp #' ' ; Skip leading spaces beq next - - - - found: cmp #'"' ; Is the argument quoted? beq setterm ; Jump if so dex ; Reset pointer to first argument character - - + lda #' ' ; A space ends the argument setterm:sta term ; Set end of argument marker ; Now, store a pointer, to the argument, into the next slot. txa ; Get low byte - clc - adc #<BUFEDT - bcc L4 + clc + adc #<BUFEDT + bcc L4 inc L5+1 -L4: - ;add #<args +L4: sta argv,y ; argv[y]=&arg L5: lda #>BUFEDT - ;adc #>args sta argv+1,y iny iny @@ -106,8 +94,6 @@ argloop:lda BUFEDT,x cmp #MAXARGS ; Maximum number of arguments reached? bcc next ; Parse next one if not - - done: lda #<argv ldx #>argv @@ -116,7 +102,6 @@ done: lda #<argv rts - .segment "INIT" term: .res 1 @@ -127,8 +112,6 @@ term: .res 1 name: .res FNAME_LEN + 1 args: .res SCREEN_XSIZE * 2 - 1 -ptr_current: - .res 2 param_found: .res 1 ; char* argv[MAXARGS+1]={name}; diff --git a/libsrc/telemon30/mym.s b/libsrc/telestrat/mym.s similarity index 99% rename from libsrc/telemon30/mym.s rename to libsrc/telestrat/mym.s index f387f9d64..009ccf53b 100644 --- a/libsrc/telemon30/mym.s +++ b/libsrc/telestrat/mym.s @@ -1,7 +1,7 @@ .export _Mym_MusicStart .importzp sp,tmp2,tmp3,tmp1,ptr1 - .include "telemon30.inc" + .include "telestrat.inc" ; To check: AYC ; http://cpcwiki.eu/index.php/AYC diff --git a/libsrc/telemon30/_open.s b/libsrc/telestrat/open.s similarity index 65% rename from libsrc/telemon30/_open.s rename to libsrc/telestrat/open.s index 7ea2d8310..9455855da 100644 --- a/libsrc/telemon30/_open.s +++ b/libsrc/telestrat/open.s @@ -1,12 +1,13 @@ .export _open - .import addysp,popax - .importzp sp,tmp2,tmp3,tmp1 + .import addysp,popax + .importzp sp,tmp2,tmp3,tmp1 - ; int open (const char* name, int flags, ...); /* May take a mode argument */ - .include "telemon30.inc" - .include "errno.inc" - .include "fcntl.inc" - + + .include "telestrat.inc" + .include "errno.inc" + .include "fcntl.inc" + +; int open (const char* name, int flags, ...); /* May take a mode argument */ .proc _open ; Throw away any additional parameters passed through the ellipsis @@ -24,9 +25,9 @@ parmok: jsr popax ; Get flagss ; Get the filename from stack and parse it. Bail out if is not ok jsr popax ; Get name - ldy tmp3 ; Get flags again - BRK_TELEMON XOPEN ; launch primitive ROM - rts + ldy tmp3 ; Get flags again + BRK_TELEMON XOPEN ; launch primitive ROM + rts .endproc \ No newline at end of file diff --git a/libsrc/telemon30/orixhdr.s b/libsrc/telestrat/orixhdr.s similarity index 56% rename from libsrc/telemon30/orixhdr.s rename to libsrc/telestrat/orixhdr.s index 1b0351885..c2a65d9fa 100644 --- a/libsrc/telemon30/orixhdr.s +++ b/libsrc/telestrat/orixhdr.s @@ -1,6 +1,6 @@ ; -; Based on code by Debrune Jérôme <jede@oric.org> -; 2016-03-17, Greg King +; By Debrune Jérôme <jede@oric.org> + ; ; The following symbol is used by the linker config. file @@ -13,23 +13,23 @@ ; ------------------------------------------------------------------------ -; Oric cassette-tape header +; Orix header see http://orix.oric.org/doku.php?id=orix:header for specs .segment "ORIXHDR" .byte $01, $00 ; - .byte "ori" + .byte "ori" - .byte $01 ; version - .byte $00,%00000000 ; 6502 only - .byte $00,$00 ; Extends - .byte $00,$00 ; OS + .byte $01 ; version + .byte $00,%00000000 ; 6502 only + .byte $00,$00 ; Extends + .byte $00,$00 ; OS .byte $00 ; reserved .byte $00 ; auto - .word __BASHEAD_START__ ; Address of start of file - .word __MAIN_LAST__ - 1 ; Address of end of file - .word __BASHEAD_START__ ; Address of start of file + .word __BASHEAD_START__ ; Address of start of file + .word __MAIN_LAST__ - 1 ; Address of end of file + .word __BASHEAD_START__ ; Address of start of file diff --git a/libsrc/telemon24/oserrlist.s b/libsrc/telestrat/oserrlist.s similarity index 100% rename from libsrc/telemon24/oserrlist.s rename to libsrc/telestrat/oserrlist.s diff --git a/libsrc/telemon24/oserror.s b/libsrc/telestrat/oserror.s similarity index 100% rename from libsrc/telemon24/oserror.s rename to libsrc/telestrat/oserror.s diff --git a/libsrc/telestrat/print.s b/libsrc/telestrat/print.s new file mode 100644 index 000000000..9942e3ad9 --- /dev/null +++ b/libsrc/telestrat/print.s @@ -0,0 +1,16 @@ +; jede jede@oric.org 2017-01-22 + +; void print (char * str); + .export _print + .import popax + .importzp tmp1 + .include "telestrat.inc" + +.proc _print + stx tmp1 + ldy tmp1 + BRK_TELEMON XWSTR0 + rts +.endproc + + diff --git a/libsrc/telestrat/read.s b/libsrc/telestrat/read.s new file mode 100644 index 000000000..4bccbfc48 --- /dev/null +++ b/libsrc/telestrat/read.s @@ -0,0 +1,43 @@ +; +; jede jede@oric.org 2017-01-22 +; + + + .FEATURE c_comments,labels_without_colons,pc_assignment, loose_char_term + .export _read + + .import popax + + .include "zeropage.inc" + .include "telestrat.inc" + +; int read (int fd, void* buf, unsigned count); + +.proc _read + sta ptr1 ; count + stx ptr1+1 ; count + jsr popax ; get buf + + sta PTR_READ_DEST + stx PTR_READ_DEST+1 + sta ptr2 ; in order to calculate nb of bytes read + stx ptr2+1 ; + + ; jsr popax ; fp pointer don't care in this version + + lda ptr1 ; + ldy ptr1+1 ; + BRK_TELEMON XFREAD ; calls telemon30 routine + ; compute nb of bytes read + lda PTR_READ_DEST+1 + sec + sbc ptr2+1 + tax + lda PTR_READ_DEST + sec + sbc ptr2 + ; Here A and X contains number of bytes read + rts +.endproc + + diff --git a/libsrc/telemon24/_scrsize.s b/libsrc/telestrat/scrsize.s similarity index 85% rename from libsrc/telemon24/_scrsize.s rename to libsrc/telestrat/scrsize.s index 305e41c46..75bd456ce 100644 --- a/libsrc/telemon24/_scrsize.s +++ b/libsrc/telestrat/scrsize.s @@ -6,7 +6,7 @@ ; .export screensize - .include "telemon24.inc" + .include "telestrat.inc" .proc screensize diff --git a/libsrc/telestrat/sound.s b/libsrc/telestrat/sound.s new file mode 100644 index 000000000..3718debd4 --- /dev/null +++ b/libsrc/telestrat/sound.s @@ -0,0 +1,42 @@ +; +; jede jede@oric.org 2017-01-22 + + .export _kbdclick1,_oups,_ping,_explode,_shoot,_zap + .include "telestrat.inc" + +.proc _kbdclick1 + ldx #<sound_bip_keyboard + ldy #>sound_bip_keyboard + BRK_TELEMON XSONPS + rts +sound_bip_keyboard: + .byte $1f,$00,$00,$00,$00,$00,$00,$3e,$10,$00,$00,$1f,$00,$00 +.endproc + +.proc _explode + BRK_TELEMON XEXPLO + rts +.endproc + +.proc _oups + BRK_TELEMON XOUPS + rts +.endproc + +.proc _ping + BRK_TELEMON XPING + rts +.endproc + +.proc _shoot + BRK_TELEMON XSHOOT + rts +.endproc + +.proc _zap + BRK_TELEMON XZAP + rts +.endproc + + + diff --git a/libsrc/telemon24/sysuname.s b/libsrc/telestrat/sysuname.s similarity index 100% rename from libsrc/telemon24/sysuname.s rename to libsrc/telestrat/sysuname.s diff --git a/libsrc/telemon30/write.s b/libsrc/telestrat/write.s similarity index 86% rename from libsrc/telemon30/write.s rename to libsrc/telestrat/write.s index d762eb92c..1c0190531 100644 --- a/libsrc/telemon30/write.s +++ b/libsrc/telestrat/write.s @@ -1,17 +1,13 @@ ; -; Ullrich von Bassewitz, 2003-04-13 -; -; int write (int fd, const void* buf, int count); -; -; This function is a hack! -; +; jede jede@oric.org 2017-01-22 .export _write .import popax .importzp ptr1, ptr2, ptr3, tmp1 - .include "telemon30.inc" + .include "telestrat.inc" +; int write (int fd, const void* buf, int count); .proc _write sta ptr3 @@ -58,8 +54,8 @@ L2: ldy #0 tax cpx #$0A ; Check for \n bne L3 - BRK_TELEMON XWR0 ; Macro - lda #$0d ; return to the beggining of the line + BRK_TELEMON XWR0 ; Macro send char to screen (channel 0 in telemon terms) + lda #$0D ; return to the beggining of the line BRK_TELEMON XWR0 ; Macro ; diff --git a/src/ca65/main.c b/src/ca65/main.c index 1e0c5996f..471afbbe8 100644 --- a/src/ca65/main.c +++ b/src/ca65/main.c @@ -291,12 +291,8 @@ static void SetSys (const char* Sys) NewSymbol ("__ATMOS__", 1); break; - case TGT_TELEMON24: - NewSymbol ("__TELEMON24__", 1); - break; - - case TGT_TELEMON30: - NewSymbol ("__TELEMON30__", 1); + case TGT_TELESTRAT: + NewSymbol ("__TELESTRAT__", 1); break; case TGT_NES: diff --git a/src/cc65/main.c b/src/cc65/main.c index b0c9261fe..872f66aff 100644 --- a/src/cc65/main.c +++ b/src/cc65/main.c @@ -243,14 +243,10 @@ static void SetSys (const char* Sys) DefineNumericMacro ("__ATMOS__", 1); break; - case TGT_TELEMON24: - DefineNumericMacro ("__TELEMON24__", 1); + case TGT_TELESTRAT: + DefineNumericMacro ("__TELESTRAT__", 1); break; - case TGT_TELEMON30: - DefineNumericMacro ("__TELEMON30__", 1); - break; - case TGT_NES: DefineNumericMacro ("__NES__", 1); break; diff --git a/src/common/target.c b/src/common/target.c index 67e4ad51b..219afc809 100644 --- a/src/common/target.c +++ b/src/common/target.c @@ -171,8 +171,7 @@ static const TargetEntry TargetMap[] = { { "sim6502", TGT_SIM6502 }, { "sim65c02", TGT_SIM65C02 }, { "supervision", TGT_SUPERVISION }, - { "telemon24", TGT_TELEMON24 }, - { "telemon30", TGT_TELEMON30 }, + { "telestrat", TGT_TELESTRAT }, { "vic20", TGT_VIC20 }, }; #define MAP_ENTRY_COUNT (sizeof (TargetMap) / sizeof (TargetMap[0])) @@ -201,8 +200,7 @@ static const TargetProperties PropertyTable[TGT_COUNT] = { { "geos-apple", CPU_65C02, BINFMT_BINARY, CTNone }, { "lunix", CPU_6502, BINFMT_O65, CTNone }, { "atmos", CPU_6502, BINFMT_BINARY, CTNone }, - { "telemon24", CPU_6502, BINFMT_BINARY, CTNone }, - { "telemon30", CPU_6502, BINFMT_BINARY, CTNone }, + { "telestrat", CPU_6502, BINFMT_BINARY, CTNone }, { "nes", CPU_6502, BINFMT_BINARY, CTNone }, { "supervision", CPU_65SC02, BINFMT_BINARY, CTNone }, { "lynx", CPU_65SC02, BINFMT_BINARY, CTNone }, diff --git a/src/common/target.h b/src/common/target.h index 68c0953fe..7409505bf 100644 --- a/src/common/target.h +++ b/src/common/target.h @@ -73,8 +73,7 @@ typedef enum { TGT_GEOS_APPLE, TGT_LUNIX, TGT_ATMOS, - TGT_TELEMON24, - TGT_TELEMON30, + TGT_TELESTRAT, TGT_NES, TGT_SUPERVISION, TGT_LYNX, From 6f58b9a22d255429aaba8c45972c09d39f2256c2 Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Tue, 31 Jan 2017 22:20:19 +0100 Subject: [PATCH 16/29] Correcting comments alignment Correcting an address error in telestrat.inc when cleaning files which broke read.s primitive --- asminc/telestrat.inc | 14 +++++++------- libsrc/telestrat/read.s | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/asminc/telestrat.inc b/asminc/telestrat.inc index fedda1946..24a1aa538 100644 --- a/asminc/telestrat.inc +++ b/asminc/telestrat.inc @@ -27,7 +27,7 @@ RESB := $02 TR0 := $0C TR1 := $0D -PTR_READ_DEST := $2D ; used for XFREAD and XWRITE only in telemon 3.0 +PTR_READ_DEST := $2C ; used for XFREAD and XWRITE only in telemon 3.0 HRSX := $46 HRSY := $47 @@ -108,12 +108,12 @@ XWSTR0 = $14 XTEXT = $19 XHIRES = $1A XMINMA = $1F -XFREAD = $27 ; only in TELEMON 3.0 -XOPEN = $30 ; only in TELEMON 3.0 -XCOSCR = $34 ; switch off cursor -XCSSCR = $35 ; switch on cursor -XCLOSE = $3A ; only in TELEMON 3.0 Close file -XFWRITE = $3B ; only in TELEMON 3.0 write file +XFREAD = $27 ; only in TELEMON 3.0 +XOPEN = $30 ; only in TELEMON 3.0 +XCOSCR = $34 ; switch off cursor +XCSSCR = $35 ; switch on cursor +XCLOSE = $3A ; only in TELEMON 3.0 Close file +XFWRITE = $3B ; only in TELEMON 3.0 write file XSONPS = $40 XOUPS = $42 XPLAY = $43 diff --git a/libsrc/telestrat/read.s b/libsrc/telestrat/read.s index 4bccbfc48..85a6132eb 100644 --- a/libsrc/telestrat/read.s +++ b/libsrc/telestrat/read.s @@ -3,13 +3,13 @@ ; - .FEATURE c_comments,labels_without_colons,pc_assignment, loose_char_term - .export _read - - .import popax - - .include "zeropage.inc" - .include "telestrat.inc" + .FEATURE c_comments,labels_without_colons,pc_assignment, loose_char_term + .export _read + + .import popax + + .include "zeropage.inc" + .include "telestrat.inc" ; int read (int fd, void* buf, unsigned count); From 37185b20dd354d22fc6591c204830d780b657610 Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Tue, 31 Jan 2017 22:21:53 +0100 Subject: [PATCH 17/29] correcting README.md to add telestrat target --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b62ac761d..26ca98cef 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ including - the Nintendo Entertainment System (NES) console. - the Watara Supervision console. - the Oric Atmos. +- the Oric telestrat. - the Lynx console. - the Ohio Scientific Challenger 1P. From d9778994fab808b829cc15dd612fd48a18271c0f Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Tue, 31 Jan 2017 22:33:19 +0100 Subject: [PATCH 18/29] Correcting some spaces --- libsrc/telestrat/ch376.s | 48 ++++++++++++++++++------------------- libsrc/telestrat/close.s | 4 ++-- libsrc/telestrat/graphics.s | 2 +- libsrc/telestrat/mainargs.s | 6 ++--- libsrc/telestrat/open.s | 35 +++++++++++++-------------- 5 files changed, 47 insertions(+), 48 deletions(-) diff --git a/libsrc/telestrat/ch376.s b/libsrc/telestrat/ch376.s index fbfa16017..49aefad92 100644 --- a/libsrc/telestrat/ch376.s +++ b/libsrc/telestrat/ch376.s @@ -29,49 +29,49 @@ CH376_USB_INT_SUCCESS = $14 CH376_USB_INT_CONNECT = $15 CH376_USB_INT_DISCONNECT = $16 CH376_USB_INT_BUF_OVER = $17 -CH376_USB_INT_USB_READY = $18 -CH376_USB_INT_DISK_READ = $1D +CH376_USB_INT_USB_READY = $18 +CH376_USB_INT_DISK_READ = $1D CH376_USB_INT_DISK_WRITE = $1E CH376_USB_INT_DISK_ERR = $1F -CH376_ERR_OPEN_DIR = $41 -CH376_ERR_MISS_FILE = $42 +CH376_ERR_OPEN_DIR = $41 +CH376_ERR_MISS_FILE = $42 CH376_ERR_FOUND_NAME = $43 CH376_ERR_DISK_DISCON = $82 CH376_ERR_LARGE_SECTOR = $84 CH376_ERR_TYPE_ERROR = $92 -CH376_ERR_BPB_ERROR = $A1 -CH376_ERR_DISK_FULL = $B1 -CH376_ERR_FDT_OVER = $B2 +CH376_ERR_BPB_ERROR = $A1 +CH376_ERR_DISK_FULL = $B1 +CH376_ERR_FDT_OVER = $B2 CH376_ERR_FILE_CLOSE = $B4 -CH376_GET_IC_VER = $01 -CH376_SET_BAUDRATE = $02 +CH376_GET_IC_VER = $01 +CH376_SET_BAUDRATE = $02 CH376_GET_ENTER_SLEEP = $03 -CH376_RESET_ALL = $05 -CH376_CHECK_EXIST = $06 +CH376_RESET_ALL = $05 +CH376_CHECK_EXIST = $06 CH376_GET_FILE_SIZE = $0C CH376_SET_USB_MODE = $15 CH376_GET_STATUS = $22 CH376_RD_USB_DATA0 = $27 -CH376_CMD_WR_REQ_DATA = $2D -CH376_SET_FILE_NAME = $2F +CH376_CMD_WR_REQ_DATA = $2D +CH376_SET_FILE_NAME = $2F CH376_DISK_CONNECT = $30 ; check the disk connection status -CH376_DISK_MOUNT = $31 -CH376_FILE_OPEN = $32 -CH376_FILE_ENUM_GO = $33 -CH376_FILE_CREATE = $34 +CH376_DISK_MOUNT = $31 +CH376_FILE_OPEN = $32 +CH376_FILE_ENUM_GO = $33 +CH376_FILE_CREATE = $34 CH376_FILE_CLOSE = $36 -CH376_BYTE_LOCATE = $39 -CH376_BYTE_READ = $3A -CH376_BYTE_RD_GO = $3B -CH376_BYTE_WRITE = $3C -CH376_BYTE_WR_GO = $3D -CH376_DISK_CAPACITY = $3E -CH376_DISK_RD_GO = $55 +CH376_BYTE_LOCATE = $39 +CH376_BYTE_READ = $3A +CH376_BYTE_RD_GO = $3B +CH376_BYTE_WRITE = $3C +CH376_BYTE_WR_GO = $3D +CH376_DISK_CAPACITY = $3E +CH376_DISK_RD_GO = $55 .proc _ch376_file_close lda #CH376_FILE_CLOSE diff --git a/libsrc/telestrat/close.s b/libsrc/telestrat/close.s index 881d0897f..240ebb063 100644 --- a/libsrc/telestrat/close.s +++ b/libsrc/telestrat/close.s @@ -2,9 +2,9 @@ .export _close - .import addysp,popax + .import addysp,popax - .include "zeropage.inc" + .include "zeropage.inc" .include "telestrat.inc" .include "errno.inc" .include "fcntl.inc" diff --git a/libsrc/telestrat/graphics.s b/libsrc/telestrat/graphics.s index 9984036bb..e0b002d3c 100644 --- a/libsrc/telestrat/graphics.s +++ b/libsrc/telestrat/graphics.s @@ -4,7 +4,7 @@ .include "zeropage.inc" .include "telestrat.inc" - .import popa + .import popa .proc _paper diff --git a/libsrc/telestrat/mainargs.s b/libsrc/telestrat/mainargs.s index b41e2a96d..fa388cbfa 100644 --- a/libsrc/telestrat/mainargs.s +++ b/libsrc/telestrat/mainargs.s @@ -24,8 +24,8 @@ initmainargs: ldx #0 ; Limit the length L0: lda BUFEDT,x - beq L3 - cmp #' ' + beq L3 + cmp #' ' bne L1 lda #0 beq L3 @@ -35,7 +35,7 @@ L1: sta name,x bne L0 lda #0 L3: - sta name,x + sta name,x inc __argc ; argc always is equal to, at least, 1 diff --git a/libsrc/telestrat/open.s b/libsrc/telestrat/open.s index 9455855da..b3b390003 100644 --- a/libsrc/telestrat/open.s +++ b/libsrc/telestrat/open.s @@ -1,33 +1,32 @@ - .export _open - .import addysp,popax - .importzp sp,tmp2,tmp3,tmp1 + .export _open + .import addysp,popax + .importzp sp,tmp2,tmp3,tmp1 - .include "telestrat.inc" - .include "errno.inc" - .include "fcntl.inc" + .include "telestrat.inc" + .include "errno.inc" + .include "fcntl.inc" ; int open (const char* name, int flags, ...); /* May take a mode argument */ .proc _open ; Throw away any additional parameters passed through the ellipsis - dey ; Parm count < 4 shouldn't be needed to be... - dey ; ...checked (it generates a c compiler warning) - dey - dey - beq parmok ; Branch if parameter count ok - jsr addysp ; Fix stack, throw away unused parameters + dey ; Parm count < 4 shouldn't be needed to be... + dey ; ...checked (it generates a c compiler warning) + dey + dey + beq parmok ; Branch if parameter count ok + jsr addysp ; Fix stack, throw away unused parameters ; Parameters ok. Pop the flags and save them into tmp3 parmok: jsr popax ; Get flagss - sta tmp3 ; save flags + sta tmp3 ; save flags ; Get the filename from stack and parse it. Bail out if is not ok - - jsr popax ; Get name - ldy tmp3 ; Get flags again - BRK_TELEMON XOPEN ; launch primitive ROM - rts + jsr popax ; Get name + ldy tmp3 ; Get flags again + BRK_TELEMON XOPEN ; launch primitive ROM + rts .endproc \ No newline at end of file From 0e649f24eae9812bd1cfa3f9955caecb8ceb7b9e Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Wed, 1 Feb 2017 23:58:33 +0100 Subject: [PATCH 19/29] Correcting some code from github comments --- README.md | 2 +- asminc/telestrat.inc | 9 +- cfg/telestrat.cfg | 3 - doc/telestrat.sgml | 57 ++-- include/telestrat.h | 4 +- libsrc/telestrat/ch376.s | 344 ------------------- libsrc/telestrat/graphics.s | 58 ---- libsrc/telestrat/keyboard.s | 14 - libsrc/telestrat/mym.s | 626 ----------------------------------- libsrc/telestrat/orixhdr.s | 26 +- libsrc/telestrat/oserrlist.s | 75 ----- libsrc/telestrat/oserror.s | 17 - libsrc/telestrat/print.s | 16 - 13 files changed, 51 insertions(+), 1200 deletions(-) delete mode 100644 libsrc/telestrat/ch376.s delete mode 100644 libsrc/telestrat/graphics.s delete mode 100644 libsrc/telestrat/keyboard.s delete mode 100644 libsrc/telestrat/mym.s delete mode 100644 libsrc/telestrat/oserrlist.s delete mode 100644 libsrc/telestrat/oserror.s delete mode 100644 libsrc/telestrat/print.s diff --git a/README.md b/README.md index 26ca98cef..16e92e878 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ including - the Nintendo Entertainment System (NES) console. - the Watara Supervision console. - the Oric Atmos. -- the Oric telestrat. +- the Oric Telestrat. - the Lynx console. - the Ohio Scientific Challenger 1P. diff --git a/asminc/telestrat.inc b/asminc/telestrat.inc index 24a1aa538..2c3502ba8 100644 --- a/asminc/telestrat.inc +++ b/asminc/telestrat.inc @@ -24,8 +24,8 @@ FNAME_LEN = 11 ; maximum length of file-name RES := $00 RESB := $02 -TR0 := $0C -TR1 := $0D +TR0 := $0C +TR1 := $0D PTR_READ_DEST := $2C ; used for XFREAD and XWRITE only in telemon 3.0 @@ -123,10 +123,11 @@ XZAP = $46 XSHOOT = $47 XCIRCL = $8F XCURSE = $90 -XEXPLO = $9C -XPING = $9D XPAPER = $92 XINK = $93 +XEXPLO = $9C +XPING = $9D + ; --------------------------------------------------------------------------- ; Page $500 diff --git a/cfg/telestrat.cfg b/cfg/telestrat.cfg index b9f0b4026..395a936e1 100644 --- a/cfg/telestrat.cfg +++ b/cfg/telestrat.cfg @@ -1,9 +1,6 @@ SYMBOLS { - __ORIXHDR__: type = import; - __STACKSIZE__: type = weak, value = $0800; # 2K stack - __RAMEND__: type = weak, value = $9800; } MEMORY { diff --git a/doc/telestrat.sgml b/doc/telestrat.sgml index ce9e044b4..b981fbfaf 100644 --- a/doc/telestrat.sgml +++ b/doc/telestrat.sgml @@ -10,7 +10,7 @@ <abstract> An overview over the Telestrat (telemon 3.0 : http://orix.oric.org) runtime system as it is implemented for the cc65 C -compiler. +compiler.) </abstract> <!-- Table of contents --> @@ -21,21 +21,35 @@ compiler. <sect>Overview<p> This file contains an overview of the Telestrat runtime system as it comes with the -cc65 C compiler. It describes the memory layout, Telemon3.0-specific header files, +cc65 C compiler. It describes the memory layout, Telestrat-specific header files, available drivers, and any pitfalls specific to that platform. -Please note that Telemon3.0-specific functions are just mentioned here, they are +Please note that Telestrat-specific functions are just mentioned here, they are described in detail in the separate <url url="funcref.html" name="function reference">. Even functions marked as "platform dependent" may be available on more than one platform. Please see the function reference for more information. - - <sect>Binary format<p> -The standard binary output format generated by the linker for the Telemon 3.0 target -is a machine language program with a 20 bytes header described here : http://orix.oric.org/doku.php?id=orix:header +The standard binary output format generated the linker for the Telestrat target +is a machine language program with a 20 bytes header described here : http://orix.oric.org/doku.php?id=orix:header + +This header is used for Telemon 3.0. + +Anyway, for Telemon 2.4, there is no file management, there is no TAPE routine in telemon, there is no way to load a binary easiy. + +Stratsed (the Telestrat operating system) handles files management. Stratsed is loaded to memory from floppy disk. + +There is no tool to insert a binary in a Stratsed floppy disk. + +The only way to load a binary (for Telemon 2.4) is to : +<itemize> +<item>remove the 20 bytes header +<item>download osdk : http://osdk.defence-force.org/index?page=download +<item>use Floppybuilder in OSDK to insert the binary with the tool (please read FloppyBuilder manual to insert your binary, and to start microdisc boot sector when telestrat starts) +</itemize> + @@ -64,12 +78,12 @@ Special locations: <sect>Platform-specific header files<p> -Programs containing Telemon 3.0 -specific code may use the <tt/telemon.h/ header file. +Programs containing Telestrat -specific code may use the <tt/telestrat.h/ header file. -<sect1>Telemon 3.0-specific functions<p> +<sect1>Telestrat-specific functions<p> -The functions listed below are special for the Telemon 3.0. See the <url +The functions listed below are special for the Telestrat. See the <url url="funcref.html" name="function reference"> for declaration and usage. <itemize> @@ -77,13 +91,13 @@ url="funcref.html" name="function reference"> for declaration and usage. <item>ping <item>shoot <item>zap -<item>oupsx +<item>oups </itemize> <sect1>Hardware access<p> -The following pseudo variables declared in the <tt/atmos.h/ header file do allow +The following pseudo variables declared in the <tt/telestrat.h/ header file do allow access to hardware located in the address space. Some variables are structures; accessing the struct fields will access the chip registers. @@ -99,30 +113,23 @@ structures; accessing the struct fields will access the chip registers. <sect>Loadable drivers<p> -<em>Note:</em> Since the Atmos doesn't have working disk I/O -(see <ref id="limitations" name="section "Limitations"">), the -available drivers cannot be loaded at runtime (so the term "loadable drivers" -is somewhat misleading). Instead, the drivers have to be statically linked. While -this may seem overhead, it has two advantages: - - <sect1>Extended memory drivers<p> -No extended memory drivers are currently available for the Atmos. +No extended memory drivers are currently available for the Telestrat. <sect1>Joystick drivers<p> <descrip> -telemon 3.0 manages joysticks but it had been handled yet. +telemon 2.4 & 3.0 manages joysticks but it had been handled yet. </descrip><p> <sect1>Mouse drivers<p> -Telemon 3.0 manages also mouse, but it had been no handled yet in this version. +Telestrat manages also mouse, but it had been no handled yet in this version. <sect1>RS232 device drivers<p> @@ -132,14 +139,12 @@ not done </descrip><p> - - <sect>Limitations<label id="limitations"><p> <sect1>Disk I/O<p> -This version handles fopen, fread, fclose primitives. Because Telemon 3.0 handles these two primitives. By the way, -it uses an extension "ch376 card" which handles sdcard and FAT 32 usb key. +This version handles fopen, fread, fclose primitives. Because Telemon 3.0 handles these three primitives. By the way, +it uses an extension "ch376 card" which handles sdcard and FAT 32 usb key. In the next version of Telemon, FT DOS, Sedoric, Stratsed will be handled in these 3 primitives. <itemize> <item>fclose diff --git a/include/telestrat.h b/include/telestrat.h index 73b018444..85da8df60 100644 --- a/include/telestrat.h +++ b/include/telestrat.h @@ -1,5 +1,5 @@ -void print (char *); + void hires(); void text(); @@ -14,8 +14,6 @@ void ink(char color); void kbdclick1(); -void curset(char x,char y, char display, char display); -void circle(char rayon); diff --git a/libsrc/telestrat/ch376.s b/libsrc/telestrat/ch376.s deleted file mode 100644 index 49aefad92..000000000 --- a/libsrc/telestrat/ch376.s +++ /dev/null @@ -1,344 +0,0 @@ - -; jede jede@oric.org 2017-01-22 - - ; For XA65 compatibily in the future - .FEATURE c_comments,labels_without_colons,pc_assignment, loose_char_term - .export _ch376_set_file_name - .export _ch376_file_open - .export _ch376_ic_get_version - .export _ch376_reset - .export _ch376_check_exist - .export _ch376_disk_mount - .export _ch376_set_usb_mode - .export _ch376_file_close - .export _ch376_seek_file - .export _ch376_file_create - .export _ch376_fwrite - - .import popax - .include "zeropage.inc" - .include "telestrat.inc" - - - - - -CH376_SET_USB_MODE_CODE_USB_HOST_SOF_PACKAGE_AUTOMATICALLY = $06 - -CH376_USB_INT_SUCCESS = $14 -CH376_USB_INT_CONNECT = $15 -CH376_USB_INT_DISCONNECT = $16 -CH376_USB_INT_BUF_OVER = $17 -CH376_USB_INT_USB_READY = $18 -CH376_USB_INT_DISK_READ = $1D -CH376_USB_INT_DISK_WRITE = $1E -CH376_USB_INT_DISK_ERR = $1F - - -CH376_ERR_OPEN_DIR = $41 -CH376_ERR_MISS_FILE = $42 -CH376_ERR_FOUND_NAME = $43 -CH376_ERR_DISK_DISCON = $82 -CH376_ERR_LARGE_SECTOR = $84 -CH376_ERR_TYPE_ERROR = $92 -CH376_ERR_BPB_ERROR = $A1 -CH376_ERR_DISK_FULL = $B1 -CH376_ERR_FDT_OVER = $B2 -CH376_ERR_FILE_CLOSE = $B4 - -CH376_GET_IC_VER = $01 -CH376_SET_BAUDRATE = $02 -CH376_GET_ENTER_SLEEP = $03 -CH376_RESET_ALL = $05 -CH376_CHECK_EXIST = $06 -CH376_GET_FILE_SIZE = $0C - -CH376_SET_USB_MODE = $15 -CH376_GET_STATUS = $22 -CH376_RD_USB_DATA0 = $27 -CH376_CMD_WR_REQ_DATA = $2D -CH376_SET_FILE_NAME = $2F - -CH376_DISK_CONNECT = $30 ; check the disk connection status -CH376_DISK_MOUNT = $31 -CH376_FILE_OPEN = $32 -CH376_FILE_ENUM_GO = $33 -CH376_FILE_CREATE = $34 -CH376_FILE_CLOSE = $36 -CH376_BYTE_LOCATE = $39 -CH376_BYTE_READ = $3A -CH376_BYTE_RD_GO = $3B -CH376_BYTE_WRITE = $3C -CH376_BYTE_WR_GO = $3D -CH376_DISK_CAPACITY = $3E -CH376_DISK_RD_GO = $55 - -.proc _ch376_file_close - lda #CH376_FILE_CLOSE - sta CH376_COMMAND - jsr _ch376_wait_response - rts -.endproc - -.proc _ch376_seek_file - ldx #CH376_BYTE_LOCATE - stx CH376_COMMAND - sta CH376_DATA - sty CH376_DATA - lda #$00 ; Don't manage 32 bits length - sta CH376_DATA - sta CH376_DATA - jsr _ch376_wait_response - rts -.endproc - -; void ch376_set_file_name(char *filename) -.proc _ch376_set_file_name - sta ptr1 - stx ptr1+1 - lda #CH376_SET_FILE_NAME ;$2f - sta CH376_COMMAND - ldy #0 -loop: - lda (ptr1),y ; replace by bufnom - beq end ; we reached 0 value - BRK_TELEMON XMINMA - sta CH376_DATA - iny - cpy #13 ; because we don't manage longfilename shortname =11 - bne loop -end: - sta CH376_DATA - rts -.endproc - -; char _ch376_file_open(); -.proc _ch376_file_open - lda #CH376_FILE_OPEN ; $32 - sta CH376_COMMAND - jsr _ch376_wait_response - rts -.endproc - -.proc _ch376_get_file_size - lda #CH376_GET_FILE_SIZE - sta CH376_COMMAND - lda #$68 - sta CH376_DATA - ; store file length 32 bits - lda CH376_DATA - sta tmp1 - lda CH376_DATA - sta tmp1+1 - lda CH376_DATA - sta tmp2 - lda CH376_DATA - sta tmp2+1 - rts -.endproc - -; void ch376_reset(); -.proc _ch376_reset - lda #CH376_RESET_ALL ; 5 - sta CH376_COMMAND - ; waiting - ldy #0 - ldx #0 -loop: - nop - inx - bne loop - iny - bne loop - rts -.endproc - -; char ch376_check_exist(char value); - -.proc _ch376_check_exist - sta tmp1 - lda #CH376_CHECK_EXIST ; - sta CH376_COMMAND - lda tmp1 - sta CH376_DATA - lda CH376_DATA - rts -.endproc - -; char ch376_ic_get_version(void) -.proc _ch376_ic_get_version - lda #CH376_GET_IC_VER - sta CH376_COMMAND - ldx #0 - lda CH376_DATA - rts -.endproc - -; void ch376_set_usb_mode(char mode) -.proc _ch376_set_usb_mode - ldx #CH376_SET_USB_MODE ; $15 - stx CH376_COMMAND - sta CH376_DATA - rts -.endproc - -; void ch376_set_bytes_write(int value); -.proc _ch376_set_bytes_write - ldy #CH376_BYTE_WRITE - sty CH376_COMMAND - sta CH376_DATA - stx CH376_DATA - lda #0 - sta CH376_DATA - sta CH376_DATA - jsr _ch376_wait_response - rts -.endproc - -.proc _ch376_set_bytes_read - ldy #CH376_BYTE_READ - sty CH376_COMMAND - ; Storing 32 bits value - sta CH376_DATA - stx CH376_DATA - lda #0 - sta CH376_DATA - sta CH376_DATA - jsr _ch376_wait_response - rts -.endproc - -; char ch376_disk_mount(); -.proc _ch376_disk_mount - lda #CH376_DISK_MOUNT ; $31 - sta CH376_COMMAND - jsr _ch376_wait_response - ; if we read data value, we have then length of the volume name - ldx #0 - rts -.endproc - - -; char ch376_wait_response(); -.proc _ch376_wait_response -; return 1 if usb controller does not respond -; else A contains answer of the controller - ldy #$FF ; We have to wait 35 ms, but well, this loop is broken when controler is OK -loop3: - ldx #$FF ; don't decrease this counter. Because ch376 won't respond if there is a lower value -loop: - lda CH376_COMMAND - and #%10000000 - cmp #128 - bne no_error - dex - bne loop - dey - bne loop3 - ; error is here - rts -no_error: - lda #CH376_GET_STATUS - sta CH376_COMMAND - lda CH376_DATA - rts -.endproc - -.proc _ch376_fread - ; use ptr1 to count bytes - jsr _ch376_set_bytes_read -continue: - cmp #CH376_USB_INT_DISK_READ ; something to read - beq we_read - cmp #CH376_USB_INT_SUCCESS ; finished - beq finished - ; TODO in A : $ff X: $ff - lda #0 - tax - rts -we_read: - lda #CH376_RD_USB_DATA0 - sta CH376_COMMAND - - lda CH376_DATA ; contains length read - sta tmp2; Number of bytes to read - - ldy #0 -loop: - lda CH376_DATA ; read the data - sta (PTR_READ_DEST),y - iny - cpy tmp2 - bne loop - tya - clc - adc PTR_READ_DEST - bcc next - inc PTR_READ_DEST+1 -next: - sta PTR_READ_DEST - - lda #CH376_BYTE_RD_GO - sta CH376_COMMAND - jsr _ch376_wait_response - jmp continue -finished: - ; TODO return bytes read - lda tmp1 - ldx tmp1+1 - rts -.endproc - -; void _ch376_fwrite(void *ptr,int number) -.proc _ch376_fwrite - ; use ptr1 to count bytes - sta ptr2 - stx ptr2+1 - - jsr popax - sta PTR_READ_DEST - stx PTR_READ_DEST+1 - - lda ptr2 - ldx ptr2+1 - jsr _ch376_set_bytes_write -continue: - cmp #CH376_USB_INT_DISK_WRITE ; something to read - beq we_read - cmp #CH376_USB_INT_SUCCESS ; finished - beq finished - - lda #0 - tax - rts -we_read: - lda #CH376_CMD_WR_REQ_DATA - sta CH376_COMMAND - - lda CH376_DATA ; contains length read - sta tmp2; Number of bytes to read - - ldy #0 -loop: - lda (PTR_READ_DEST),y - sta CH376_DATA ; read the data - dec tmp2 - bne loop - - - lda #CH376_BYTE_WR_GO - sta CH376_COMMAND - jsr _ch376_wait_response - jmp continue -finished: - lda tmp1 - ldx tmp1+1 - rts -.endproc - -.proc _ch376_file_create - lda #CH376_FILE_CREATE - sta CH376_COMMAND - jsr _ch376_wait_response - rts -.endproc diff --git a/libsrc/telestrat/graphics.s b/libsrc/telestrat/graphics.s deleted file mode 100644 index e0b002d3c..000000000 --- a/libsrc/telestrat/graphics.s +++ /dev/null @@ -1,58 +0,0 @@ -; jede jede@oric.org 2017-01-22 - - .export _paper,_hires,_text,_circle,_curset, _switchOffCursor - - .include "zeropage.inc" - .include "telestrat.inc" - .import popa - - -.proc _paper - ldx #0 ; First window - ; A contains the paper - BRK_TELEMON XPAPER - rts -.endproc - -; XINK is bugged, it corrupt memory : removing from export -.proc _ink - ldx #0 ; First window - ; A contains the ink - BRK_TELEMON XINK - rts -.endproc - -; can be optimized with a macro -.proc _hires - BRK_TELEMON XHIRES - rts -.endproc - -.proc _text - BRK_TELEMON XTEXT - rts -.endproc - -.proc _curset - jsr popa ; Pixel - jsr popa - sta HRSX - jsr popa - sta HRSY - BRK_TELEMON XCURSE - rts -.endproc - -.proc _circle - sta HRS1 - BRK_TELEMON XCIRCL - rts -.endproc - -.proc _switchOffCursor - ldx #0 - BRK_TELEMON XCOSCR - rts -.endproc - - diff --git a/libsrc/telestrat/keyboard.s b/libsrc/telestrat/keyboard.s deleted file mode 100644 index 7069d1003..000000000 --- a/libsrc/telestrat/keyboard.s +++ /dev/null @@ -1,14 +0,0 @@ -; jede jede@oric.org 2017-01-22 - - .export _key - - .include "zeropage.inc" - .include "telestrat.inc" - -; char key(void); - -.proc _key - BRK_TELEMON XRDW0 ; read keyboard - rts -.endproc - diff --git a/libsrc/telestrat/mym.s b/libsrc/telestrat/mym.s deleted file mode 100644 index 009ccf53b..000000000 --- a/libsrc/telestrat/mym.s +++ /dev/null @@ -1,626 +0,0 @@ - .export _Mym_MusicStart - .importzp sp,tmp2,tmp3,tmp1,ptr1 - - .include "telestrat.inc" - -; To check: AYC -; http://cpcwiki.eu/index.php/AYC - - - - -_DecodedByte :=$D0 ; Byte being currently decoded from the MYM stream -_DecodeBitCounter :=$D2 ; Number of bits we can read in the current byte -_DecodedResult :=$D3 ; What is returned by the 'read bits' function -_CurrentAYRegister :=$D4 ; Contains the number of the register being decoded -_RegisterBufferHigh :=$D5 ; Points to the high byte of the decoded register buffer, increment to move to the next register -_BufferFrameOffset :=$D6 ; From 0 to 127, used when filling the decoded register buffer -_MusicResetCounter :=$D7 ; 2 bytes Contains the number of rows to play before reseting -_CurrentFrame :=$D9 ; From 0 to 255 and then cycles... the index of the frame to play this vbl -_PlayerVbl :=$DA -_FrameLoadBalancer :=$DB ; We depack a new frame every 9 VBLs, this way the 14 registers are evenly depacked over 128 frames - - -VIA_1 := $30f -VIA_2 := $30c - -_MusicData := $c000 - -; mym(char *buf) - - - - -; -; Current PSG values during unpacking -; - - -.proc _Mym_MusicStart - - ; The two first bytes of the MYM music is the number of rows in the music - ; We decrement that at each frame, and when we reach zero, time to start again. - sta ptr1 - stx ptr1+1 - - ldy #0 - lda (ptr1),y - sta _MusicResetCounter+0 - iny - lda (ptr1),y - tax - inx - stx _MusicResetCounter+1 - - ;ldx _MusicData+0 - ;stx _MusicResetCounter+0 - ;ldx _MusicData+1 - ;inx - ;stx _MusicResetCounter+1 - - - ; Initialize the read bit counter - ldy #2 ; should be useless because we can do iny which earn 1 byte - - lda ptr1 - clc - adc #2 - bcc next20 - inc ptr1+1 - lda ptr1+1 - sta __auto_music_ptr+2 -next20: - sta ptr1 - sta __auto_music_ptr+1 - - - - ;lda #<(_MusicData+2) - ;sta __auto_music_ptr+1 - ;lda #>(_MusicData+2) - ;sta __auto_music_ptr+2 - - lda #1 - sta _DecodeBitCounter - - ; Clear all data - lda #0 - sta _DecodedResult - sta _DecodedByte - sta _PlayerVbl - sta _PlayerRegCurrentValue - sta _BufferFrameOffset - sta _PlayerCount - sta _CurrentAYRegister - sta _CurrentFrame - - ldx #14 -loop_init: - dex - sta _PlayerRegValues,x - bne loop_init - - - ; - ; Unpack the 128 first register frames - ; - - lda #>_PlayerBuffer - sta _RegisterBufferHigh - - ldx #0 -unpack_block_loop: - stx _CurrentAYRegister - - ; Unpack that register - jsr _PlayerUnpackRegister2 - - ; Next register - ldx _CurrentAYRegister - inx - cpx #14 - bne unpack_block_loop - - - lda #128 - sta _PlayerVbl+0 - - lda #0 - sta _PlayerCount - sta _CurrentAYRegister - sta _CurrentFrame - - lda #9 - sta _FrameLoadBalancer - - lda #1 - sta _MusicPlaying - - ; - ; Install the IRQ - ; - php - sei - lda #<_Mym_PlayFrame - sta _InterruptCallBack_3+1 - lda #>_Mym_PlayFrame - sta _InterruptCallBack_3+2 - plp - - rts - - -_Mym_MusicStop: - - ; Indicate the main code that the music is finished - lda #0 - sta _MusicPlaying - - ; Disable the IRQ so it does not conflict or cause weird things - php - sei - lda #<_DoNothing - sta _InterruptCallBack_3+1 - lda #>_DoNothing - sta _InterruptCallBack_3+2 - plp - - ; Cut the sound so it does not sounds like a dying cat - - ; y=register number - ; x=value to write - ldy #7 ; Control register - ldx #$FF - jsr _PsgPlayRegister - - ldy #8 ; Volume A - ldx #0 - jsr _PsgPlayRegister - - ldy #9 ; Volume B - ldx #0 - jsr _PsgPlayRegister - - ldy #10 ; Volume C - ldx #0 - jsr _PsgPlayRegister - rts - - -_Mym_PlayFrame: - - ; - ; Check for end of music - ; CountZero: $81,$0d - dec _MusicResetCounter+0 - bne music_contines - dec _MusicResetCounter+1 - bne music_contines - -music_resets: - jmp _Mym_MusicStop - -music_contines: - - ; - ; Play a frame of 14 registers - ; - - lda _CurrentFrame - sta _auto_psg_play_read+1 - lda #>_PlayerBuffer - sta _auto_psg_play_read+2 - - ldy #0 -register_loop: - -_auto_psg_play_read: - ldx _PlayerBuffer - - ; y=register number - ; x=value to write - jsr _PsgPlayRegister - - inc _auto_psg_play_read+2 - iny - cpy #14 - bne register_loop - - - - inc _CurrentFrame - inc _PlayerCount - - lda _CurrentAYRegister - cmp #14 - bcs end_reg - - - dec _FrameLoadBalancer - bne end - - jsr _PlayerUnpackRegister - inc _CurrentAYRegister - lda #9 - sta _FrameLoadBalancer -end: - rts - - -end_reg: - - lda _PlayerCount - cmp #128 - bcc skip2 - - lda #0 - sta _CurrentAYRegister - sta _PlayerCount - lda #9 - sta _FrameLoadBalancer - - clc - lda _PlayerVbl+0 - adc #128 - sta _PlayerVbl+0 -skip2: - - - rts - - - -; y=register number -; x=value to write -_PsgPlayRegister: - - sty VIA_1 - txa - - pha - lda VIA_2 - ora #$EE ; $EE 238 11101110 - sta VIA_2 - - and #$11 ; $11 17 00010001 - ora #$CC ; $CC 204 11001100 - sta VIA_2 - - tax - pla - sta VIA_1 - txa - ora #$EC ; $EC 236 11101100 - sta VIA_2 - - and #$11 ; $11 17 00010001 - ora #$CC ; $CC 204 11001100 - sta VIA_2 - - rts - - - - -; -; Initialise X with the number of bits to read -; Y is not modifier -; -_ReadBits: - - lda #0 - sta _DecodedResult - - ; Will iterate X times (number of bits to read) -loop_read_bits: - - dec _DecodeBitCounter - beq get_next_byte - -shift_bit: - asl _DecodedByte - rol _DecodedResult - - dex - bne loop_read_bits - rts - -get_next_byte: - ; reset mask - lda #8 - sta _DecodeBitCounter - - ; fetch a new byte, and increment the adress. -__auto_music_ptr: - lda _MusicData+2 - sta _DecodedByte - - inc __auto_music_ptr+1 - bne shift_bit - inc __auto_music_ptr+2 - jmp shift_bit - - - - - -_PlayerUnpackRegister: - lda #>_PlayerBuffer - clc - adc _CurrentAYRegister - sta _RegisterBufferHigh -_PlayerUnpackRegister2: - ; - ; Init register bit count and current value - ; - ldx _CurrentAYRegister - lda _PlayerRegValues,x - sta _PlayerRegCurrentValue - - - ; - ; Check if it's packed or not - ; and call adequate routine... - ; - ldx #1 - jsr _ReadBits - ldx _DecodedResult - bne DecompressFragment - - -UnchangedFragment: - - ; - ; No change at all, just repeat '_PlayerRegCurrentValue' 128 times - ; - lda _RegisterBufferHigh ; highpart of buffer adress + register number - sta __auto_copy_unchanged_write+2 - - ldx #128 ; 128 iterations - lda _PlayerRegCurrentValue ; Value to write - - ldy _PlayerVbl - -repeat_loop: -__auto_copy_unchanged_write: - sta _PlayerBuffer,y - iny - dex - bne repeat_loop - - - jmp player_main_return - - -player_main_return: - ; Write back register current value - ldx _CurrentAYRegister - lda _PlayerRegCurrentValue - sta _PlayerRegValues,x - - ; Move to the next register buffer - inc _RegisterBufferHigh - rts - - - - -DecompressFragment: - lda _PlayerVbl ; Either 0 or 128 at this point else we have a problem... - sta _BufferFrameOffset - -decompressFragmentLoop: - -player_copy_packed_loop: - ; Check packing method - ldx #1 - jsr _ReadBits - - ldx _DecodedResult - bne PlayerNotCopyLast - -UnchangedRegister: - - ; We just copy the current value 128 times - lda _RegisterBufferHigh ; highpart of buffer adress + register number - sta __auto_player_copy_last+2 - - ldx _BufferFrameOffset ; Value between 00 and 7f - lda _PlayerRegCurrentValue ; Value to copy -__auto_player_copy_last: - sta _PlayerBuffer,x - - inc _BufferFrameOffset - - - -player_return: - - ; Check end of loop - lda _BufferFrameOffset - and #127 - bne decompressFragmentLoop - - jmp player_main_return - - -PlayerNotCopyLast: - ; Check packing method - ldx #1 - jsr _ReadBits - - ldx _DecodedResult - beq DecompressWithOffset - -ReadNewRegisterValue: - ; Read new register value (variable bit count) - ldx _CurrentAYRegister - lda _PlayerRegBits,x - tax - jsr _ReadBits - ldx _DecodedResult - stx _PlayerRegCurrentValue - - ; Copy to stream - lda _RegisterBufferHigh ; highpart of buffer adress + register number - sta __auto_player_read_new+2 - - ldx _BufferFrameOffset ; Value between 00 and 7f - lda _PlayerRegCurrentValue ; New value to write -__auto_player_read_new: - sta _PlayerBuffer,x - - inc _BufferFrameOffset - jmp player_return - - - - -DecompressWithOffset: - - ; Read Offset (0 to 127) - ldx #7 - jsr _ReadBits - - lda _RegisterBufferHigh ; highpart of buffer adress + register number - sta __auto_write+2 ; Write adress - sta __auto_read+2 ; Read adress - - ; Compute wrap around offset... - lda _BufferFrameOffset ; between 0 and 255 - clc - adc _DecodedResult ; + Offset Between 00 and 7f - sec - sbc #128 ; -128 - tay - - ; Read count (7 bits) - ldx #7 - jsr _ReadBits - - inc _DecodedResult ; 1 to 129 - - - ldx _BufferFrameOffset - -player_copy_offset_loop: - -__auto_read: - lda _PlayerBuffer,y ; Y for reading - iny - -__auto_write: - sta _PlayerBuffer,x ; X for writing - - inx - dec _DecodedResult - bne player_copy_offset_loop - - stx _BufferFrameOffset - sta _PlayerRegCurrentValue - - jmp player_return - - - - -; -; Size in bits of each PSG register -; -_PlayerRegBits: - ; Chanel A Frequency - .byt 8 - .byt 4 - - ; Chanel B Frequency - .byt 8 - .byt 4 - - ; Chanel C Frequency - .byt 8 - .byt 4 - - ; Chanel sound generator - .byt 5 - - ; select - .byt 8 - - ; Volume A,B,C - .byt 5 - .byt 5 - .byt 5 - - ; Wave period - .byt 8 - .byt 8 - - ; Wave form - .byt 8 - -_PlayerCount: - .res 1,0 ; must be equal to 0 -_MusicPlaying: - .res 1,0 ; must be equal to 0 - - -_PlayerRegValues: -_RegisterChanAFrequency: - ; Chanel A Frequency - .res 1,8 - .res 1,4 - -_RegisterChanBFrequency: - ; Chanel B Frequency - .res 1,8 - .res 1,4 - -_RegisterChanCFrequency: - ; Chanel C Frequency - .res 1,8 - .res 1,4 - -_RegisterChanNoiseFrequency: - ; Chanel sound generator - .res 1,5 - - ; select - .res 1,8 - - ; Volume A,B,C -_RegisterChanAVolume: - .res 1,5 -_RegisterChanBVolume: - .res 1,5 -_RegisterChanCVolume: - .res 1,5 - - ; Wave period - .res 1,8 - .res 1,8 - - ; Wave form - .res 1,8 - -_PlayerRegCurrentValue: - .res 1,0 -_DoNothing: - rts - -_InterruptCallBack_3: ; Used by the music player - jsr _DoNothing ; Transformed to "jsr _Mym_PlayFrame" -> 12 cycles - -; jsr MiniScrollLoading ; -> 338 cycles - - pla - tay - pla - tax - pla - - rti -_PlayerBuffer: - .res 256*14 ; About 3.5 kilobytes somewhere in memory, we put the music file in overlay memory - -.endproc - diff --git a/libsrc/telestrat/orixhdr.s b/libsrc/telestrat/orixhdr.s index c2a65d9fa..6fe2fca73 100644 --- a/libsrc/telestrat/orixhdr.s +++ b/libsrc/telestrat/orixhdr.s @@ -3,13 +3,13 @@ ; - ; The following symbol is used by the linker config. file - ; to force this module to be included into the output file. - .export __ORIXHDR__:abs = 1 + ; The following symbol is used by the linker config. file + ; to force this module to be included into the output file. + .export __ORIXHDR__:abs = 1 - ; These symbols, also, come from the configuration file. - .import __AUTORUN__, __PROGFLAG__ - .import __BASHEAD_START__, __MAIN_LAST__ + ; These symbols, also, come from the configuration file. + .import __AUTORUN__, __PROGFLAG__ + .import __BASHEAD_START__, __MAIN_LAST__ ; ------------------------------------------------------------------------ @@ -17,17 +17,17 @@ .segment "ORIXHDR" - .byte $01, $00 ; + .byte $01, $00 ; non C64 marker (same as o65 format) - .byte "ori" + .byte "ori" ; magic number - .byte $01 ; version - .byte $00,%00000000 ; 6502 only - .byte $00,$00 ; Extends - .byte $00,$00 ; OS + .byte $01 ; version of the header + .byte $00,%00000000 ; 6502 only + .byte $00,$00 ; type of language + .byte $00,$00 ; OS version .byte $00 ; reserved - .byte $00 ; auto + .byte $00 ; auto or not .word __BASHEAD_START__ ; Address of start of file .word __MAIN_LAST__ - 1 ; Address of end of file diff --git a/libsrc/telestrat/oserrlist.s b/libsrc/telestrat/oserrlist.s deleted file mode 100644 index 8ec41de6d..000000000 --- a/libsrc/telestrat/oserrlist.s +++ /dev/null @@ -1,75 +0,0 @@ -; -; Stefan Haubenthal, 2004-05-25 -; Ullrich von Bassewitz, 18.07.2002 -; -; Defines the platform specific error list. -; -; The table is built as a list of entries -; -; .byte entrylen -; .byte errorcode -; .asciiz errormsg -; -; and terminated by an entry with length zero that is returned if the -; error code could not be found. -; - - .export __sys_oserrlist - -;---------------------------------------------------------------------------- -; Macros used to generate the list (may get moved to an include file?) - -; Regular entry -.macro sys_oserr_entry code, msg - .local Start, End -Start: .byte End - Start - .byte code - .asciiz msg -End: -.endmacro - -; Sentinel entry -.macro sys_oserr_sentinel msg - .byte 0 ; Length is always zero - .byte 0 ; Code is unused - .asciiz msg -.endmacro - -;---------------------------------------------------------------------------- -; The error message table - -.rodata - -__sys_oserrlist: - sys_oserr_entry 1, "File not found" - sys_oserr_entry 2, "Invalid command end" - sys_oserr_entry 3, "No drive number" - sys_oserr_entry 4, "Bad drive number" - sys_oserr_entry 5, "Invalid filename" - sys_oserr_entry 6, "fderr=(error number)" - sys_oserr_entry 7, "Illegal attribute" - sys_oserr_entry 8, "Wildcard(s) not allowed" - sys_oserr_entry 9, "File already exists" - sys_oserr_entry 10, "Insufficient disc space" - sys_oserr_entry 11, "File open" - sys_oserr_entry 12, "Illegal quantity" - sys_oserr_entry 13, "End address missing" - sys_oserr_entry 14, "Start address > end address" - sys_oserr_entry 15, "Missing 'to'" - sys_oserr_entry 16, "Renamed file not on same disc" - sys_oserr_entry 17, "Unknown array" - sys_oserr_entry 18, "Target drive not source drive" - sys_oserr_entry 19, "Destination not specified" - sys_oserr_entry 20, "Cannot merge and overwrite" - sys_oserr_entry 21, "Single target file illegal" - sys_oserr_entry 22, "Syntax" - sys_oserr_entry 23, "Filename missing" - sys_oserr_entry 24, "Source file missing" - sys_oserr_entry 25, "Type mismatch" - sys_oserr_entry 26, "Disc write-protected" - sys_oserr_entry 27, "Incompatible drives" - sys_oserr_entry 28, "File not open" - sys_oserr_entry 29, "File end" - sys_oserr_sentinel "Unknown error" - - diff --git a/libsrc/telestrat/oserror.s b/libsrc/telestrat/oserror.s deleted file mode 100644 index 37c9bd7fc..000000000 --- a/libsrc/telestrat/oserror.s +++ /dev/null @@ -1,17 +0,0 @@ -; -; Stefan Haubenthal, 2011-04-18 -; -; int __fastcall__ _osmaperrno (unsigned char oserror); -; /* Map a system specific error into a system independent code */ -; - - .include "errno.inc" - .export __osmaperrno - -.proc __osmaperrno - - lda #<EUNKNOWN - ldx #>EUNKNOWN - rts - -.endproc diff --git a/libsrc/telestrat/print.s b/libsrc/telestrat/print.s deleted file mode 100644 index 9942e3ad9..000000000 --- a/libsrc/telestrat/print.s +++ /dev/null @@ -1,16 +0,0 @@ -; jede jede@oric.org 2017-01-22 - -; void print (char * str); - .export _print - .import popax - .importzp tmp1 - .include "telestrat.inc" - -.proc _print - stx tmp1 - ldy tmp1 - BRK_TELEMON XWSTR0 - rts -.endproc - - From bbff709d9f74c783831cad0ffacc79f65772a2f8 Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Thu, 2 Feb 2017 00:00:21 +0100 Subject: [PATCH 20/29] Correcting return line --- doc/telestrat.sgml | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/telestrat.sgml b/doc/telestrat.sgml index b981fbfaf..d31457fad 100644 --- a/doc/telestrat.sgml +++ b/doc/telestrat.sgml @@ -150,7 +150,6 @@ it uses an extension "ch376 card" which handles sdcard and FAT 32 usb key. In th <item>fclose <item>fopen <item>fread - </itemize> From 4b77072fed541a3635ed2b6ec7d3b5f521c5500a Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Thu, 2 Feb 2017 00:05:50 +0100 Subject: [PATCH 21/29] Correcting alignment --- libsrc/telestrat/close.s | 2 +- libsrc/telestrat/mainargs.s | 12 ++++++------ libsrc/telestrat/write.s | 36 +++++++++++++++++------------------- 3 files changed, 24 insertions(+), 26 deletions(-) diff --git a/libsrc/telestrat/close.s b/libsrc/telestrat/close.s index 240ebb063..04d8788d1 100644 --- a/libsrc/telestrat/close.s +++ b/libsrc/telestrat/close.s @@ -6,7 +6,7 @@ .include "zeropage.inc" .include "telestrat.inc" - .include "errno.inc" + .include "errno.inc" .include "fcntl.inc" ; int open (const char* name, int flags, ...); /* May take a mode argument */ diff --git a/libsrc/telestrat/mainargs.s b/libsrc/telestrat/mainargs.s index fa388cbfa..41c3a5131 100644 --- a/libsrc/telestrat/mainargs.s +++ b/libsrc/telestrat/mainargs.s @@ -26,14 +26,14 @@ initmainargs: L0: lda BUFEDT,x beq L3 cmp #' ' - bne L1 - lda #0 - beq L3 + bne L1 + lda #0 + beq L3 L1: sta name,x inx - cpx #FNAME_LEN + cpx #FNAME_LEN bne L0 - lda #0 + lda #0 L3: sta name,x inc __argc ; argc always is equal to, at least, 1 @@ -57,7 +57,7 @@ setterm:sta term ; Set end of argument marker ; Now, store a pointer, to the argument, into the next slot. txa ; Get low byte - clc + clc adc #<BUFEDT bcc L4 inc L5+1 diff --git a/libsrc/telestrat/write.s b/libsrc/telestrat/write.s index 1c0190531..278c28c83 100644 --- a/libsrc/telestrat/write.s +++ b/libsrc/telestrat/write.s @@ -24,25 +24,23 @@ stx ptr1+1 jsr popax ; get fd and discard - ; if fd=0001 then it stdout - - - cpx #0 - beq next - jmp L1 + ; if fd=0001 then it stdout + cpx #0 + beq next + jmp L1 next: - cmp #1 - beq L1 + cmp #1 + beq L1 - ; Here it's a file opened - lda ptr1 - sta PTR_READ_DEST - lda ptr1+1 - sta PTR_READ_DEST+1 - lda ptr3 - ldy ptr3+1 - BRK_TELEMON XFWRITE - rts + ; Here it's a file opened + lda ptr1 + sta PTR_READ_DEST + lda ptr1+1 + sta PTR_READ_DEST+1 + lda ptr3 + ldy ptr3+1 + BRK_TELEMON XFWRITE + rts L1: inc ptr2 @@ -54,9 +52,9 @@ L2: ldy #0 tax cpx #$0A ; Check for \n bne L3 - BRK_TELEMON XWR0 ; Macro send char to screen (channel 0 in telemon terms) + BRK_TELEMON XWR0 ; Macro send char to screen (channel 0 in telemon terms) lda #$0D ; return to the beggining of the line - BRK_TELEMON XWR0 ; Macro ; + BRK_TELEMON XWR0 ; Macro ; ldx #$0D From 5abb40b229a3bc6a52ef70dbf1b50cd44f81c418 Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Thu, 2 Feb 2017 00:11:11 +0100 Subject: [PATCH 22/29] Last push for tonight :) --- libsrc/telestrat/open.s | 23 +++++++++++++---------- libsrc/telestrat/read.s | 4 +--- libsrc/telestrat/write.s | 2 +- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/libsrc/telestrat/open.s b/libsrc/telestrat/open.s index b3b390003..8e94de311 100644 --- a/libsrc/telestrat/open.s +++ b/libsrc/telestrat/open.s @@ -1,6 +1,8 @@ - .export _open - .import addysp,popax - .importzp sp,tmp2,tmp3,tmp1 + .export _open + + .import addysp,popax + + .importzp sp,tmp2,tmp3,tmp1 .include "telestrat.inc" @@ -15,17 +17,18 @@ dey ; ...checked (it generates a c compiler warning) dey dey - beq parmok ; Branch if parameter count ok - jsr addysp ; Fix stack, throw away unused parameters + beq parmok ; Branch if parameter count ok + jsr addysp ; Fix stack, throw away unused parameters ; Parameters ok. Pop the flags and save them into tmp3 -parmok: jsr popax ; Get flagss - sta tmp3 ; save flags +parmok: + jsr popax ; Get flagss + sta tmp3 ; save flags ; Get the filename from stack and parse it. Bail out if is not ok - jsr popax ; Get name - ldy tmp3 ; Get flags again - BRK_TELEMON XOPEN ; launch primitive ROM + jsr popax ; Get name + ldy tmp3 ; Get flags again + BRK_TELEMON XOPEN ; launch primitive ROM rts .endproc diff --git a/libsrc/telestrat/read.s b/libsrc/telestrat/read.s index 85a6132eb..75766cda2 100644 --- a/libsrc/telestrat/read.s +++ b/libsrc/telestrat/read.s @@ -2,8 +2,6 @@ ; jede jede@oric.org 2017-01-22 ; - - .FEATURE c_comments,labels_without_colons,pc_assignment, loose_char_term .export _read .import popax @@ -11,7 +9,7 @@ .include "zeropage.inc" .include "telestrat.inc" -; int read (int fd, void* buf, unsigned count); +;int read (int fd, void* buf, unsigned count); .proc _read sta ptr1 ; count diff --git a/libsrc/telestrat/write.s b/libsrc/telestrat/write.s index 278c28c83..1d269887d 100644 --- a/libsrc/telestrat/write.s +++ b/libsrc/telestrat/write.s @@ -59,7 +59,7 @@ L2: ldy #0 ldx #$0D L3: - BRK_TELEMON XWR0 ; Macro + BRK_TELEMON XWR0 ; Macro inc ptr1 bne L1 From ad6e54c2d8c470f44d1a5ee3fe45e2ce2ba9bd0d Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Thu, 2 Feb 2017 22:44:06 +0100 Subject: [PATCH 23/29] Updating doc --- doc/telestrat.sgml | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/doc/telestrat.sgml b/doc/telestrat.sgml index d31457fad..c04e14f54 100644 --- a/doc/telestrat.sgml +++ b/doc/telestrat.sgml @@ -9,7 +9,7 @@ <date>2017-01-22 <abstract> -An overview over the Telestrat (telemon 3.0 : http://orix.oric.org) runtime system as it is implemented for the cc65 C +An overview over the Telestrat (Telemon 3.0 : http://orix.oric.org) runtime system as it is implemented for the cc65 C compiler.) </abstract> @@ -37,7 +37,7 @@ is a machine language program with a 20 bytes header described here : http://ori This header is used for Telemon 3.0. -Anyway, for Telemon 2.4, there is no file management, there is no TAPE routine in telemon, there is no way to load a binary easiy. +Anyway, for Telemon 2.4, there is no file management, there is no TAPE routine in Telemon, there is no way to load a binary easily. Stratsed (the Telestrat operating system) handles files management. Stratsed is loaded to memory from floppy disk. @@ -47,10 +47,12 @@ The only way to load a binary (for Telemon 2.4) is to : <itemize> <item>remove the 20 bytes header <item>download osdk : http://osdk.defence-force.org/index?page=download -<item>use Floppybuilder in OSDK to insert the binary with the tool (please read FloppyBuilder manual to insert your binary, and to start microdisc boot sector when telestrat starts) +<item>use Floppybuilder in OSDK to insert the binary with the tool (please read FloppyBuilder manual to insert your binary, and to start microdisc boot sector when Telestrat starts) </itemize> +Please note also, that the binary converted into TAP file, will not produce a right stratsed file when tap2dsk and old2mfm are used. You will be in the case that Telestrat/Stratsed crashed when you do "DIR" command. +If you know the Stratsed disk format, please contact the author of this doc. <sect>Memory layout<p> @@ -60,7 +62,6 @@ In the standard setup, cc65-generated programs use the memory from available. ROM calls are possible without further precautions. - Special locations: <descrip> @@ -110,7 +111,6 @@ structures; accessing the struct fields will access the chip registers. </descrip><p> - <sect>Loadable drivers<p> <sect1>Extended memory drivers<p> @@ -124,27 +124,31 @@ No extended memory drivers are currently available for the Telestrat. telemon 2.4 & 3.0 manages joysticks but it had been handled yet. -</descrip><p> +</descrip> <sect1>Mouse drivers<p> +<descrip> + Telestrat manages also mouse, but it had been no handled yet in this version. +</descrip> + <sect1>RS232 device drivers<p> <descrip> -not done +Telestrat has a RS232 port, but it's not used -</descrip><p> +</descrip>< <sect>Limitations<label id="limitations"><p> <sect1>Disk I/O<p> -This version handles fopen, fread, fclose primitives. Because Telemon 3.0 handles these three primitives. By the way, -it uses an extension "ch376 card" which handles sdcard and FAT 32 usb key. In the next version of Telemon, FT DOS, Sedoric, Stratsed will be handled in these 3 primitives. +Telemon 3.0 handles fopen, fread, fclose primitives. It means that this function will crash the Telestrat because Telemon 2.4 did not have not these primitives. +By the way, Telemon 3.0 uses an extension "ch376 card" which handles sdcard and FAT 32 usb key. In the next version of Telemon, FT DOS, Sedoric, Stratsed will be handled in these 3 primitives (fopen, fread, fclose). <itemize> <item>fclose From d76911d38a8544c3351977e2a8edd81a3bcb75e7 Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Thu, 2 Feb 2017 22:53:28 +0100 Subject: [PATCH 24/29] Fixing telestrat.h --- include/telestrat.h | 34 +++++++++++++++++++++++++++++----- libsrc/telestrat/close.s | 2 -- libsrc/telestrat/mainargs.s | 2 +- libsrc/telestrat/open.s | 4 +--- libsrc/telestrat/write.s | 2 +- 5 files changed, 32 insertions(+), 12 deletions(-) diff --git a/include/telestrat.h b/include/telestrat.h index 85da8df60..5a090647b 100644 --- a/include/telestrat.h +++ b/include/telestrat.h @@ -1,17 +1,41 @@ +/*****************************************************************************/ +/* */ +/* telestrat.h */ +/* */ +/* Oric Telestrat system-specific definitions */ +/* */ +/* */ +/* */ +/* (C) 2017 Debrune Jérome, <jede@oric.org> */ +/* */ +/* */ +/* This software is provided 'as-is', without any expressed or implied */ +/* warranty. In no event will the authors be held liable for any damages */ +/* arising from the use of this software. */ +/* */ +/* Permission is granted to anyone to use this software for any purpose, */ +/* including commercial applications, and to alter it and redistribute it */ +/* freely, subject to the following restrictions: */ +/* */ +/* 1. The origin of this software must not be misrepresented; you must not */ +/* claim that you wrote the original software. If you use this software */ +/* in a product, an acknowledgment in the product documentation would be */ +/* appreciated but is not required. */ +/* 2. Altered source versions must be plainly marked as such, and must not */ +/* be misrepresented as being the original software. */ +/* 3. This notice may not be removed or altered from any source */ +/* distribution. */ +/* */ +/*****************************************************************************/ -void hires(); -void text(); void oups(); void ping(); void zap(); void shoot(); void explode(); -void paper(char color); -void ink(char color); - void kbdclick1(); diff --git a/libsrc/telestrat/close.s b/libsrc/telestrat/close.s index 04d8788d1..40e2c10b3 100644 --- a/libsrc/telestrat/close.s +++ b/libsrc/telestrat/close.s @@ -14,5 +14,3 @@ BRK_TELEMON XCLOSE ; launch primitive ROM rts .endproc - - \ No newline at end of file diff --git a/libsrc/telestrat/mainargs.s b/libsrc/telestrat/mainargs.s index 41c3a5131..0c9e799da 100644 --- a/libsrc/telestrat/mainargs.s +++ b/libsrc/telestrat/mainargs.s @@ -8,7 +8,7 @@ .constructor initmainargs, 24 .import __argc, __argv - .import ptr1 + .import ptr1 .include "telestrat.inc" .macpack generic diff --git a/libsrc/telestrat/open.s b/libsrc/telestrat/open.s index 8e94de311..08910f4f2 100644 --- a/libsrc/telestrat/open.s +++ b/libsrc/telestrat/open.s @@ -27,9 +27,7 @@ parmok: sta tmp3 ; save flags ; Get the filename from stack and parse it. Bail out if is not ok jsr popax ; Get name - ldy tmp3 ; Get flags again + ldy tmp3 ; Get flags again BRK_TELEMON XOPEN ; launch primitive ROM rts .endproc - - \ No newline at end of file diff --git a/libsrc/telestrat/write.s b/libsrc/telestrat/write.s index 1d269887d..8c2bc08f7 100644 --- a/libsrc/telestrat/write.s +++ b/libsrc/telestrat/write.s @@ -53,7 +53,7 @@ L2: ldy #0 cpx #$0A ; Check for \n bne L3 BRK_TELEMON XWR0 ; Macro send char to screen (channel 0 in telemon terms) - lda #$0D ; return to the beggining of the line + lda #$0D ; return to the beggining of the line BRK_TELEMON XWR0 ; Macro ; From d2fc2c74fb40a8d3a02b412560e71853c19207fb Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Fri, 3 Feb 2017 21:11:37 +0100 Subject: [PATCH 25/29] Correcting scrsize.s into _scrsize.s --- libsrc/telestrat/{scrsize.s => _scrsize.s} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename libsrc/telestrat/{scrsize.s => _scrsize.s} (100%) diff --git a/libsrc/telestrat/scrsize.s b/libsrc/telestrat/_scrsize.s similarity index 100% rename from libsrc/telestrat/scrsize.s rename to libsrc/telestrat/_scrsize.s From 69e3bbea7eba3c97802cf8fa94f581432ee5300c Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Tue, 7 Feb 2017 07:33:27 -0500 Subject: [PATCH 26/29] Reverted 'Used more mundane addressing in some of the instructions in "zlib/inflatemem.s".' This reverted some of commit e7e65044e607f15b7d5b4e55abf7cdcb123993a8. --- libsrc/zlib/inflatemem.s | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/libsrc/zlib/inflatemem.s b/libsrc/zlib/inflatemem.s index ea550c074..b3a0510c5 100644 --- a/libsrc/zlib/inflatemem.s +++ b/libsrc/zlib/inflatemem.s @@ -1,10 +1,15 @@ ; ; 2003-09-21, Piotr Fusik -; 2016-07-19, Greg King +; 2017-02-07, Greg King ; ; unsigned __fastcall__ inflatemem (char* dest, const char* source); ; +; Two "lda (0,x)" instructions can't be assembled for the PC-Engine library +; because an implied ".setdp $2000" changes $00 into a non-zero-page address. +; Therefore, this file isn't assembled for that target. +.ifndef __PCE__ + .export _inflatemem .import incsp2 @@ -139,8 +144,8 @@ inflateCopyBlock: ldy #1 sty getBit_hold ; Get 16-bit length - ldx #0 - lda (inputPointer,x) + ldx #inputPointer + lda (0,x) sta moveBlock_len lda (inputPointer),y sta moveBlock_len+1 @@ -165,15 +170,15 @@ moveBlock: .endif inc moveBlock_len+1 moveBlock_1: - lda (inputPointer,x) + lda (0,x) .if (.cpu & CPU_ISET_65SC02) sta (outputPointer) .else sta (outputPointer),y .endif - inc inputPointer + inc 0,x bne moveBlock_2 - inc inputPointer+1 + inc 1,x moveBlock_2: inc outputPointer bne moveBlock_3 @@ -671,3 +676,5 @@ bitsPointer_h: ; Sorted codes. sortedCodes: .res 256+1+29+30+2 + +.endif From 9cde534b232572b30456b2d4574d0ef0f0ccad0b Mon Sep 17 00:00:00 2001 From: jede <jede@oric.org> Date: Thu, 9 Feb 2017 18:46:56 +0100 Subject: [PATCH 27/29] Rollback for *.vcxproj, telestrat.sgml modified for "don't" instead of "did not" for telemon2.4 --- doc/telestrat.sgml | 2 +- src/ar65.vcxproj | 6 +++--- src/ca65.vcxproj | 6 +++--- src/cc65.vcxproj | 6 +++--- src/chrcvt65.vcxproj | 6 +++--- src/cl65.vcxproj | 6 +++--- src/co65.vcxproj | 6 +++--- src/common.vcxproj | 6 +++--- src/da65.vcxproj | 8 +++++--- src/grc65.vcxproj | 6 +++--- src/ld65.vcxproj | 6 +++--- src/od65.vcxproj | 6 +++--- src/sim65.vcxproj | 6 +++--- src/sp65.vcxproj | 6 +++--- 14 files changed, 42 insertions(+), 40 deletions(-) diff --git a/doc/telestrat.sgml b/doc/telestrat.sgml index c04e14f54..9032156ee 100644 --- a/doc/telestrat.sgml +++ b/doc/telestrat.sgml @@ -147,7 +147,7 @@ Telestrat has a RS232 port, but it's not used <sect1>Disk I/O<p> -Telemon 3.0 handles fopen, fread, fclose primitives. It means that this function will crash the Telestrat because Telemon 2.4 did not have not these primitives. +Telemon 3.0 handles fopen, fread, fclose primitives. It means that this function will crash the Telestrat because Telemon 2.4 does not have these primitives. By the way, Telemon 3.0 uses an extension "ch376 card" which handles sdcard and FAT 32 usb key. In the next version of Telemon, FT DOS, Sedoric, Stratsed will be handled in these 3 primitives (fopen, fread, fclose). <itemize> diff --git a/src/ar65.vcxproj b/src/ar65.vcxproj index 003a5fa69..b077134ce 100644 --- a/src/ar65.vcxproj +++ b/src/ar65.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -18,12 +18,12 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> diff --git a/src/ca65.vcxproj b/src/ca65.vcxproj index fb7cf2e26..4e02fa2a9 100644 --- a/src/ca65.vcxproj +++ b/src/ca65.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -18,12 +18,12 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> diff --git a/src/cc65.vcxproj b/src/cc65.vcxproj index aa85b0936..1c1f993fe 100644 --- a/src/cc65.vcxproj +++ b/src/cc65.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -18,12 +18,12 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> diff --git a/src/chrcvt65.vcxproj b/src/chrcvt65.vcxproj index d120399d1..1daf7cae9 100644 --- a/src/chrcvt65.vcxproj +++ b/src/chrcvt65.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -18,12 +18,12 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> diff --git a/src/cl65.vcxproj b/src/cl65.vcxproj index b6ceb161a..64c1126b1 100644 --- a/src/cl65.vcxproj +++ b/src/cl65.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -18,12 +18,12 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> diff --git a/src/co65.vcxproj b/src/co65.vcxproj index 89eed36e1..c66c8aac8 100644 --- a/src/co65.vcxproj +++ b/src/co65.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -18,12 +18,12 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> diff --git a/src/common.vcxproj b/src/common.vcxproj index c466d9712..053d23981 100644 --- a/src/common.vcxproj +++ b/src/common.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -113,13 +113,13 @@ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <ConfigurationType>StaticLibrary</ConfigurationType> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> <ConfigurationType>StaticLibrary</ConfigurationType> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> diff --git a/src/da65.vcxproj b/src/da65.vcxproj index cf297fd32..2695edc08 100644 --- a/src/da65.vcxproj +++ b/src/da65.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -18,12 +18,12 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> @@ -86,6 +86,7 @@ <ClCompile Include="da65\infofile.c" /> <ClCompile Include="da65\labels.c" /> <ClCompile Include="da65\main.c" /> + <ClCompile Include="da65\opc4510.c" /> <ClCompile Include="da65\opc6502.c" /> <ClCompile Include="da65\opc6502x.c" /> <ClCompile Include="da65\opc65816.c" /> @@ -109,6 +110,7 @@ <ClInclude Include="da65\handler.h" /> <ClInclude Include="da65\infofile.h" /> <ClInclude Include="da65\labels.h" /> + <ClInclude Include="da65\opc4510.h" /> <ClInclude Include="da65\opc6502.h" /> <ClInclude Include="da65\opc6502x.h" /> <ClInclude Include="da65\opc65816.h" /> diff --git a/src/grc65.vcxproj b/src/grc65.vcxproj index afac0cce1..211ad7cce 100644 --- a/src/grc65.vcxproj +++ b/src/grc65.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -18,12 +18,12 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> diff --git a/src/ld65.vcxproj b/src/ld65.vcxproj index cc5598aad..acb9b4240 100644 --- a/src/ld65.vcxproj +++ b/src/ld65.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -18,12 +18,12 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> diff --git a/src/od65.vcxproj b/src/od65.vcxproj index 2ace26001..c788ac961 100644 --- a/src/od65.vcxproj +++ b/src/od65.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -18,12 +18,12 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> diff --git a/src/sim65.vcxproj b/src/sim65.vcxproj index 9ba0980ba..f87b4db6b 100644 --- a/src/sim65.vcxproj +++ b/src/sim65.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -18,12 +18,12 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> diff --git a/src/sp65.vcxproj b/src/sp65.vcxproj index 6e7d992d4..8db98346c 100644 --- a/src/sp65.vcxproj +++ b/src/sp65.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -18,12 +18,12 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v140</PlatformToolset> + <PlatformToolset>v120</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> From 4266e712f25383a2a5dbabb0161240f8c989b9f1 Mon Sep 17 00:00:00 2001 From: Piotr Fusik <fox@scene.pl> Date: Sun, 12 Feb 2017 11:41:11 +0100 Subject: [PATCH 28/29] Optimize inflatemem. The new version is 30% shorter and 10% faster. It also avoids the indirect-X addressing mode, which was a problem for PC-Engine. --- libsrc/zlib/inflatemem.s | 954 +++++++++++++++++---------------------- 1 file changed, 404 insertions(+), 550 deletions(-) diff --git a/libsrc/zlib/inflatemem.s b/libsrc/zlib/inflatemem.s index b3a0510c5..27802fbff 100644 --- a/libsrc/zlib/inflatemem.s +++ b/libsrc/zlib/inflatemem.s @@ -1,43 +1,41 @@ ; -; 2003-09-21, Piotr Fusik -; 2017-02-07, Greg King +; 2017-02-12, Piotr Fusik ; ; unsigned __fastcall__ inflatemem (char* dest, const char* source); ; - -; Two "lda (0,x)" instructions can't be assembled for the PC-Engine library -; because an implied ".setdp $2000" changes $00 into a non-zero-page address. -; Therefore, this file isn't assembled for that target. -.ifndef __PCE__ +; NOTE: Be extremely careful with modifications, because this code is heavily +; optimized for size (for example assumes certain register and flag values +; when its internal routines return). Test with the gunzip65 sample. +; .export _inflatemem .import incsp2 - .importzp sp, sreg, ptr1, ptr2, ptr3, ptr4, tmp1 - - .macpack cpu + .importzp sp, sreg, ptr1, ptr2, ptr3, ptr4 ; -------------------------------------------------------------------------- ; ; Constants ; -; Maximum length of a Huffman code. -MAX_BITS = 15 +; Argument values for getBits. +GET_1_BIT = $81 +GET_2_BITS = $82 +GET_3_BITS = $84 +GET_4_BITS = $88 +GET_5_BITS = $90 +GET_6_BITS = $a0 +GET_7_BITS = $c0 -; All Huffman trees are stored in the bitsCount, bitsPointer_l -; and bitsPointer_h arrays. There may be two trees: the literal/length tree -; and the distance tree, or just one - the temporary tree. +; Huffman trees. +TREE_SIZE = 16 +PRIMARY_TREE = 0 +DISTANCE_TREE = TREE_SIZE -; Index in the mentioned arrays for the beginning of the literal/length tree -; or the temporary tree. -PRIMARY_TREE = 0 - -; Index in the mentioned arrays for the beginning of the distance tree. -DISTANCE_TREE = MAX_BITS - -; Size of each array. -TREES_SIZE = 2*MAX_BITS +; Alphabet. +LENGTH_SYMBOLS = 1+29+2 ; EOF, 29 length symbols, two unused symbols +DISTANCE_SYMBOLS = 30 +CONTROL_SYMBOLS = LENGTH_SYMBOLS+DISTANCE_SYMBOLS ; -------------------------------------------------------------------------- @@ -46,30 +44,26 @@ TREES_SIZE = 2*MAX_BITS ; ; Pointer to the compressed data. -inputPointer := ptr1 ; 2 bytes +inputPointer := ptr1 ; 2 bytes ; Pointer to the uncompressed data. -outputPointer := ptr2 ; 2 bytes +outputPointer := ptr2 ; 2 bytes ; Local variables. ; As far as there is no conflict, same memory locations are used ; for different variables. -inflateDynamicBlock_cnt := ptr3 ; 1 byte -inflateCodes_src := ptr3 ; 2 bytes -buildHuffmanTree_src := ptr3 ; 2 bytes -getNextLength_last := ptr3 ; 1 byte -getNextLength_index := ptr3+1 ; 1 byte - -buildHuffmanTree_ptr := ptr4 ; 2 bytes -fetchCode_ptr := ptr4 ; 2 bytes -getBits_tmp := ptr4 ; 1 byte - -moveBlock_len := sreg ; 2 bytes -inflateDynamicBlock_np := sreg ; 1 byte -inflateDynamicBlock_nd := sreg+1 ; 1 byte - -getBit_hold := tmp1 ; 1 byte +inflateStored_pageCounter := ptr3 ; 1 byte +inflateDynamic_symbol := ptr3 ; 1 byte +inflateDynamic_lastLength := ptr3+1 ; 1 byte + .assert ptr4 = ptr3 + 2, error, "Need three bytes for inflateDynamic_tempCodes" +inflateDynamic_tempCodes := ptr3+1 ; 3 bytes +inflateDynamic_allCodes := inflateDynamic_tempCodes+1 ; 1 byte +inflateDynamic_primaryCodes := inflateDynamic_tempCodes+2 ; 1 byte +inflateCodes_sourcePointer := ptr3 ; 2 bytes +inflateCodes_lengthMinus2 := ptr4 ; 1 byte +getBits_base := sreg ; 1 byte +getBit_buffer := sreg+1 ; 1 byte ; -------------------------------------------------------------------------- @@ -83,45 +77,59 @@ _inflatemem: sta inputPointer stx inputPointer+1 ; outputPointer = dest -.if (.cpu & CPU_ISET_65SC02) - lda (sp) ldy #1 -.else - ldy #0 - lda (sp),y - iny -.endif - sta outputPointer lda (sp),y sta outputPointer+1 + dey + lda (sp),y + sta outputPointer -; ldy #1 - sty getBit_hold -inflatemem_1: +; ldy #0 + sty getBit_buffer + +inflate_blockLoop: ; Get a bit of EOF and two bits of block type - ldx #3 - lda #0 +; ldy #0 + sty getBits_base + lda #GET_3_BITS jsr getBits lsr a ; A and Z contain block type, C contains EOF flag ; Save EOF flag php -; Go to the routine decompressing this block - jsr callExtr - plp - bcc inflatemem_1 -; C flag is set! + bne inflateCompressed -; return outputPointer - dest; +; Decompress a 'stored' data block. +; ldy #0 + sty getBit_buffer ; ignore bits until byte boundary + jsr getWord ; skip the length we don't need + jsr getWord ; get the two's complement length + sta inflateStored_pageCounter + bcs inflateStored_firstByte ; jmp +inflateStored_copyByte: + jsr getByte +; sec +inflateStoreByte: + jsr storeByte + bcc inflateCodes_loop +inflateStored_firstByte: + inx + bne inflateStored_copyByte + inc inflateStored_pageCounter + bne inflateStored_copyByte + +; Block decompressed. +inflate_nextBlock: + plp + bcc inflate_blockLoop + +; Decompression complete. +; return outputPointer - dest lda outputPointer -.if (.cpu & CPU_ISET_65SC02) - sbc (sp) ; C flag is set - ldy #1 -.else - ldy #0 - sbc (sp),y ; C flag is set +; ldy #0 +; sec + sbc (sp),y iny -.endif pha lda outputPointer+1 sbc (sp),y @@ -130,442 +138,346 @@ inflatemem_1: ; pop dest jmp incsp2 -; -------------------------------------------------------------------------- -; Go to proper block decoding routine. - -callExtr: - bne inflateCompressedBlock - -; -------------------------------------------------------------------------- -; Decompress a 'stored' data block. - -inflateCopyBlock: -; Ignore bits until byte boundary - ldy #1 - sty getBit_hold -; Get 16-bit length - ldx #inputPointer - lda (0,x) - sta moveBlock_len - lda (inputPointer),y - sta moveBlock_len+1 -; Skip the length and one's complement of it - lda #4 - clc - adc inputPointer - sta inputPointer - bcc moveBlock - inc inputPointer+1 -; jmp moveBlock - -; -------------------------------------------------------------------------- -; Copy block of length moveBlock_len from (0,x) to the output. - -moveBlock: - ldy moveBlock_len - beq moveBlock_1 -.if (.cpu & CPU_ISET_65SC02) -.else - ldy #0 -.endif - inc moveBlock_len+1 -moveBlock_1: - lda (0,x) -.if (.cpu & CPU_ISET_65SC02) - sta (outputPointer) -.else - sta (outputPointer),y -.endif - inc 0,x - bne moveBlock_2 - inc 1,x -moveBlock_2: - inc outputPointer - bne moveBlock_3 - inc outputPointer+1 -moveBlock_3: -.if (.cpu & CPU_ISET_65SC02) - dey -.else - dec moveBlock_len -.endif - bne moveBlock_1 - dec moveBlock_len+1 - bne moveBlock_1 - rts - -; -------------------------------------------------------------------------- +inflateCompressed: ; Decompress a Huffman-coded data block -; (A = 1: fixed, A = 2: dynamic). +; A=1: fixed block, initialize with fixed codes +; A=2: dynamic block, start by clearing all code lengths +; A=3: invalid compressed data, not handled in this routine + eor #2 -inflateCompressedBlock: - lsr a - bne inflateDynamicBlock -; Note: inflateDynamicBlock may assume that A = 1 - -; -------------------------------------------------------------------------- -; Decompress a Huffman-coded data block with default Huffman trees -; (defined by the DEFLATE format): -; literalCodeLength: 144 times 8, 112 times 9 -; endCodeLength: 7 -; lengthCodeLength: 23 times 7, 6 times 8 -; distanceCodeLength: 30 times 5+DISTANCE_TREE, 2 times 8 -; (two 8-bit codes from the primary tree are not used). - -inflateFixedBlock: - ldx #159 - stx distanceCodeLength+32 - lda #8 -inflateFixedBlock_1: - sta literalCodeLength-1,x - sta literalCodeLength+159-1,x - dex - bne inflateFixedBlock_1 - ldx #112 -; lda #9 -inflateFixedBlock_2: - inc literalCodeLength+144-1,x ; sta - dex - bne inflateFixedBlock_2 - ldx #24 -; lda #7 -inflateFixedBlock_3: - dec endCodeLength-1,x ; sta - dex - bne inflateFixedBlock_3 - ldx #30 - lda #5+DISTANCE_TREE -inflateFixedBlock_4: - sta distanceCodeLength-1,x - dex - bne inflateFixedBlock_4 - beq inflateCodes ; branch always - -; -------------------------------------------------------------------------- -; Decompress a Huffman-coded data block, reading Huffman trees first. - -inflateDynamicBlock: -; numberOfPrimaryCodes = 257 + getBits(5) - ldx #5 -; lda #1 - jsr getBits - sta inflateDynamicBlock_np -; numberOfDistanceCodes = 1 + getBits(5) - ldx #5 - lda #1+29+1 - jsr getBits - sta inflateDynamicBlock_nd -; numberOfTemporaryCodes = 4 + getBits(4) - lda #4 +; ldy #0 +inflateCompressed_setCodeLengths: tax - jsr getBits - sta inflateDynamicBlock_cnt -; Get lengths of temporary codes in the order stored in tempCodeLengthOrder - txa ; lda #0 - tay -inflateDynamicBlock_1: - ldx #3 ; A = 0 - jsr getBits ; does not change Y -inflateDynamicBlock_2: - ldx tempCodeLengthOrder,y - sta literalCodeLength,x - lda #0 + beq inflateCompressed_setLiteralCodeLength +; fixed Huffman literal codes: +; 144 8-bit codes +; 112 9-bit codes + lda #4 + cpy #144 + rol a +inflateCompressed_setLiteralCodeLength: + sta literalSymbolCodeLength,y + beq inflateCompressed_setControlCodeLength +; fixed Huffman control codes: +; 24 7-bit codes +; 6 8-bit codes +; 2 meaningless 8-bit codes +; 30 5-bit distance codes + lda #5+DISTANCE_TREE + cpy #LENGTH_SYMBOLS + bcs inflateCompressed_setControlCodeLength + cpy #24 + adc #$100+2-DISTANCE_TREE +inflateCompressed_setControlCodeLength: + cpy #CONTROL_SYMBOLS + bcs inflateCompressed_noControlSymbol + sta controlSymbolCodeLength,y +inflateCompressed_noControlSymbol: iny - cpy inflateDynamicBlock_cnt - bcc inflateDynamicBlock_1 - cpy #19 - bcc inflateDynamicBlock_2 - ror literalCodeLength+19 ; C flag is set, so this will set b7 + bne inflateCompressed_setCodeLengths + + tax + beq inflateDynamic + +; Decompress a block +inflateCodes: + jsr buildHuffmanTree +inflateCodes_loop: + jsr fetchPrimaryCode + bcc inflateStoreByte + beq inflate_nextBlock +; Copy sequence from look-behind buffer +; ldy #0 + sty getBits_base + cmp #9 + bcc inflateCodes_setSequenceLength + tya +; lda #0 + cpx #1+28 + bcs inflateCodes_setSequenceLength + dex + txa + lsr a + ror getBits_base + inc getBits_base + lsr a + rol getBits_base + jsr getAMinus1BitsMax8 +; sec + adc #0 +inflateCodes_setSequenceLength: + sta inflateCodes_lengthMinus2 + ldx #DISTANCE_TREE + jsr fetchCode + cmp #4 + bcc inflateCodes_setOffsetLowByte + inc getBits_base + lsr a + jsr getAMinus1BitsMax8 +inflateCodes_setOffsetLowByte: + eor #$ff + sta inflateCodes_sourcePointer + lda getBits_base + cpx #10 + bcc inflateCodes_setOffsetHighByte + lda getNPlus1Bits_mask-10,x + jsr getBits + clc +inflateCodes_setOffsetHighByte: + eor #$ff +; clc + adc outputPointer+1 + sta inflateCodes_sourcePointer+1 + jsr copyByte + jsr copyByte +inflateCodes_copyByte: + jsr copyByte + dec inflateCodes_lengthMinus2 + bne inflateCodes_copyByte + beq inflateCodes_loop ; jmp + +inflateDynamic: +; Decompress a block reading Huffman trees first +; ldy #0 +; numberOfPrimaryCodes = 257 + getBits(5) +; numberOfDistanceCodes = 1 + getBits(5) +; numberOfTemporaryCodes = 4 + getBits(4) + ldx #3 +inflateDynamic_getHeader: + lda inflateDynamic_headerBits-1,x + jsr getBits +; sec + adc inflateDynamic_headerBase-1,x + sta inflateDynamic_tempCodes-1,x + dex + bne inflateDynamic_getHeader + +; Get lengths of temporary codes in the order stored in inflateDynamic_tempSymbols +; ldx #0 +inflateDynamic_getTempCodeLengths: + lda #GET_3_BITS + jsr getBits + ldy inflateDynamic_tempSymbols,x + sta literalSymbolCodeLength,y + ldy #0 + inx + cpx inflateDynamic_tempCodes + bcc inflateDynamic_getTempCodeLengths + ; Build the tree for temporary codes jsr buildHuffmanTree ; Use temporary codes to get lengths of literal/length and distance codes - ldx #0 - ldy #1 - stx getNextLength_last -inflateDynamicBlock_3: - jsr getNextLength - sta literalCodeLength,x - inx - bne inflateDynamicBlock_3 -inflateDynamicBlock_4: - jsr getNextLength -inflateDynamicBlock_5: - sta endCodeLength,x - inx - cpx inflateDynamicBlock_np - bcc inflateDynamicBlock_4 - lda #0 - cpx #1+29 - bcc inflateDynamicBlock_5 -inflateDynamicBlock_6: - jsr getNextLength - cmp #0 - beq inflateDynamicBlock_7 - adc #DISTANCE_TREE-1 ; C flag is set -inflateDynamicBlock_7: - sta endCodeLength,x - inx - cpx inflateDynamicBlock_nd - bcc inflateDynamicBlock_6 - ror endCodeLength,x ; C flag is set, so this will set b7 -; jmp inflateCodes - -; -------------------------------------------------------------------------- -; Decompress a data block basing on given Huffman trees. - -inflateCodes: - jsr buildHuffmanTree -inflateCodes_1: - jsr fetchPrimaryCode - bcs inflateCodes_2 -; Literal code -.if (.cpu & CPU_ISET_65SC02) - sta (outputPointer) -.else - ldy #0 - sta (outputPointer),y -.endif - inc outputPointer - bne inflateCodes_1 - inc outputPointer+1 - bcc inflateCodes_1 ; branch always -; End of block -inflateCodes_ret: - rts -inflateCodes_2: - beq inflateCodes_ret -; Restore a block from the look-behind buffer - jsr getValue - sta moveBlock_len - tya - jsr getBits - sta moveBlock_len+1 - ldx #DISTANCE_TREE - jsr fetchCode - jsr getValue - sec - eor #$ff - adc outputPointer - sta inflateCodes_src +; ldx #0 +; sec +inflateDynamic_decodeLength: +; C=1: literal codes +; C=0: control codes + stx inflateDynamic_symbol php - tya - jsr getBits - plp - eor #$ff - adc outputPointer+1 - sta inflateCodes_src+1 - ldx #inflateCodes_src - jsr moveBlock - beq inflateCodes_1 ; branch always - -; -------------------------------------------------------------------------- -; Build Huffman trees basing on code lengths (in bits). -; stored in the *CodeLength arrays. -; A byte with its highest bit set marks the end. - -buildHuffmanTree: - lda #<literalCodeLength - sta buildHuffmanTree_src - lda #>literalCodeLength - sta buildHuffmanTree_src+1 -; Clear bitsCount and bitsPointer_l - ldy #2*TREES_SIZE+1 - lda #0 -buildHuffmanTree_1: - sta bitsCount-1,y - dey - bne buildHuffmanTree_1 - beq buildHuffmanTree_3 ; branch always -; Count number of codes of each length -buildHuffmanTree_2: - tax - inc bitsPointer_l,x - iny - bne buildHuffmanTree_3 - inc buildHuffmanTree_src+1 -buildHuffmanTree_3: - lda (buildHuffmanTree_src),y - bpl buildHuffmanTree_2 -; Calculate a pointer for each length - ldx #0 - lda #<sortedCodes - ldy #>sortedCodes - clc -buildHuffmanTree_4: - sta bitsPointer_l,x - tya - sta bitsPointer_h,x - lda bitsPointer_l+1,x - adc bitsPointer_l,x ; C flag is zero - bcc buildHuffmanTree_5 - iny -buildHuffmanTree_5: - inx - cpx #TREES_SIZE - bcc buildHuffmanTree_4 - lda #>literalCodeLength - sta buildHuffmanTree_src+1 - ldy #0 - bcs buildHuffmanTree_9 ; branch always -; Put codes into their place in sorted table -buildHuffmanTree_6: - beq buildHuffmanTree_7 - tax - lda bitsPointer_l-1,x - sta buildHuffmanTree_ptr - lda bitsPointer_h-1,x - sta buildHuffmanTree_ptr+1 - tya - ldy bitsCount-1,x - inc bitsCount-1,x - sta (buildHuffmanTree_ptr),y - tay -buildHuffmanTree_7: - iny - bne buildHuffmanTree_9 - inc buildHuffmanTree_src+1 - ldx #MAX_BITS-1 -buildHuffmanTree_8: - lda bitsCount,x - sta literalCount,x - dex - bpl buildHuffmanTree_8 -buildHuffmanTree_9: - lda (buildHuffmanTree_src),y - bpl buildHuffmanTree_6 - rts - -; -------------------------------------------------------------------------- -; Decode next code length using temporary codes. - -getNextLength: - stx getNextLength_index - dey - bne getNextLength_1 ; Fetch a temporary code jsr fetchPrimaryCode ; Temporary code 0..15: put this length - ldy #1 - cmp #16 - bcc getNextLength_2 + bpl inflateDynamic_storeLengths ; Temporary code 16: repeat last length 3 + getBits(2) times ; Temporary code 17: put zero length 3 + getBits(3) times ; Temporary code 18: put zero length 11 + getBits(7) times - tay - ldx tempExtraBits-16,y - lda tempBaseValue-16,y + tax jsr getBits - cpy #17 + cpx #GET_3_BITS + bcc inflateDynamic_code16 + beq inflateDynamic_code17 +; sec + adc #7 +inflateDynamic_code17: +; ldy #0 + sty inflateDynamic_lastLength +inflateDynamic_code16: tay - txa ; lda #0 - bcs getNextLength_2 -getNextLength_1: - lda getNextLength_last -getNextLength_2: - sta getNextLength_last - ldx getNextLength_index + lda inflateDynamic_lastLength + iny + iny +inflateDynamic_storeLengths: + iny + plp + ldx inflateDynamic_symbol +inflateDynamic_storeLength: + bcc inflateDynamic_controlSymbolCodeLength + sta literalSymbolCodeLength,x + inx + cpx #1 +inflateDynamic_storeNext: + dey + bne inflateDynamic_storeLength + sta inflateDynamic_lastLength + beq inflateDynamic_decodeLength ; jmp +inflateDynamic_controlSymbolCodeLength: + cpx inflateDynamic_primaryCodes + bcc inflateDynamic_storeControl +; the code lengths we skip here were zero-initialized +; in inflateCompressed_setControlCodeLength + bne inflateDynamic_noStartDistanceTree + ldx #LENGTH_SYMBOLS +inflateDynamic_noStartDistanceTree: + ora #DISTANCE_TREE +inflateDynamic_storeControl: + sta controlSymbolCodeLength,x + inx + cpx inflateDynamic_allCodes + bcc inflateDynamic_storeNext + dey +; ldy #0 + jmp inflateCodes + +; Build Huffman trees basing on code lengths (in bits) +; stored in the *SymbolCodeLength arrays +buildHuffmanTree: +; Clear nBitCode_totalCount, nBitCode_literalCount, nBitCode_controlCount + tya +; lda #0 +buildHuffmanTree_clear: + sta nBitCode_clearFrom,y + iny + bne buildHuffmanTree_clear +; Count number of codes of each length +; ldy #0 +buildHuffmanTree_countCodeLengths: + ldx literalSymbolCodeLength,y + inc nBitCode_literalCount,x + inc nBitCode_totalCount,x + cpy #CONTROL_SYMBOLS + bcs buildHuffmanTree_noControlSymbol + ldx controlSymbolCodeLength,y + inc nBitCode_controlCount,x + inc nBitCode_totalCount,x +buildHuffmanTree_noControlSymbol: + iny + bne buildHuffmanTree_countCodeLengths +; Calculate offsets of symbols sorted by code length +; lda #0 + ldx #$100-3*TREE_SIZE +buildHuffmanTree_calculateOffsets: + sta nBitCode_literalOffset+3*TREE_SIZE-$100,x + clc + adc nBitCode_literalCount+3*TREE_SIZE-$100,x + inx + bne buildHuffmanTree_calculateOffsets +; Put symbols in their place in the sorted array +; ldy #0 +buildHuffmanTree_assignCode: + tya + ldx literalSymbolCodeLength,y + ldy nBitCode_literalOffset,x + inc nBitCode_literalOffset,x + sta codeToLiteralSymbol,y + tay + cpy #CONTROL_SYMBOLS + bcs buildHuffmanTree_noControlSymbol2 + ldx controlSymbolCodeLength,y + ldy nBitCode_controlOffset,x + inc nBitCode_controlOffset,x + sta codeToControlSymbol,y + tay +buildHuffmanTree_noControlSymbol2: + iny + bne buildHuffmanTree_assignCode rts -; -------------------------------------------------------------------------- -; Read a code basing on the primary tree. - +; Read Huffman code using the primary tree fetchPrimaryCode: ldx #PRIMARY_TREE -; jmp fetchCode - -; -------------------------------------------------------------------------- -; Read a code from input basing on the tree specified in X. +; Read a code from input using the tree specified in X. ; Return low byte of this code in A. -; For the literal/length tree, the C flag is set if the code is non-literal. - +; Return C flag reset for literal code, set for length code. fetchCode: - lda #0 -fetchCode_1: +; ldy #0 + tya +fetchCode_nextBit: jsr getBit rol a inx sec - sbc bitsCount-1,x - bcs fetchCode_1 - adc bitsCount-1,x ; C flag is zero - cmp literalCount-1,x - sta fetchCode_ptr - ldy bitsPointer_l-1,x - lda bitsPointer_h-1,x - sta fetchCode_ptr+1 - lda (fetchCode_ptr),y + sbc nBitCode_totalCount,x + bcs fetchCode_nextBit +; clc + adc nBitCode_controlCount,x + bcs fetchCode_control +; clc + adc nBitCode_literalOffset,x + tax + lda codeToLiteralSymbol,x + clc + rts +fetchCode_control: +; sec + adc nBitCode_controlOffset-1,x + tax + lda codeToControlSymbol-1,x + and #$1f ; make distance symbols zero-based + tax + sec rts -; -------------------------------------------------------------------------- -; Decode low byte of a value (length or distance), basing on the code in A. -; The result is the base value for this code plus some bits read from input. - -getValue: - tay - ldx lengthExtraBits-1,y - lda lengthBaseValue_l-1,y - pha - lda lengthBaseValue_h-1,y - tay - pla -; jmp getBits - -; -------------------------------------------------------------------------- -; Read X-bit number from the input and add it to A. -; Increment Y if overflow. -; If X > 8, read only 8 bits. -; On return X holds number of unread bits: X = (X > 8 ? X - 8 : 0); - +; Read A minus 1 bits, but no more than 8 +getAMinus1BitsMax8: + rol getBits_base + tax + cmp #9 + bcs getByte + lda getNPlus1Bits_mask-2,x getBits: - cpx #0 - beq getBits_ret -.if (.cpu & CPU_ISET_65SC02) - stz getBits_tmp - dec getBits_tmp -.else - pha - lda #$ff - sta getBits_tmp - pla -.endif -getBits_1: - jsr getBit - bcc getBits_2 - sbc getBits_tmp ; C flag is set - bcc getBits_2 - iny -getBits_2: - dex - beq getBits_ret - asl getBits_tmp - bmi getBits_1 -getBits_ret: + jsr getBits_loop +getBits_normalizeLoop: + lsr getBits_base + ror a + bcc getBits_normalizeLoop rts -; -------------------------------------------------------------------------- -; Read a single bit from input, return it in the C flag. +; Read 16 bits +getWord: + jsr getByte + tax +; Read 8 bits +getByte: + lda #$80 +getBits_loop: + jsr getBit + ror a + bcc getBits_loop + rts +; Read one bit, return in the C flag getBit: - lsr getBit_hold - bne getBit_ret + lsr getBit_buffer + bne getBit_return pha -.if (.cpu & CPU_ISET_65SC02) - lda (inputPointer) -.else - sty getBit_hold - ldy #0 +; ldy #0 lda (inputPointer),y - ldy getBit_hold -.endif inc inputPointer - bne getBit_1 + bne getBit_samePage inc inputPointer+1 -getBit_1: - ror a ; (C flag was set) - sta getBit_hold +getBit_samePage: + sec + ror a + sta getBit_buffer pla -getBit_ret: +getBit_return: + rts + +; Copy a previously written byte +copyByte: + ldy outputPointer + lda (inflateCodes_sourcePointer),y + ldy #0 +; Write a byte +storeByte: +; ldy #0 + sta (outputPointer),y + inc outputPointer + bne storeByte_return + inc outputPointer+1 + inc inflateCodes_sourcePointer+1 +storeByte_return: rts @@ -575,57 +487,17 @@ getBit_ret: ; .rodata -; -------------------------------------------------------------------------- -; Arrays for the temporary codes. -; Order, in which lengths of the temporary codes are stored. -tempCodeLengthOrder: - .byte 16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15 +getNPlus1Bits_mask: + .byte GET_1_BIT,GET_2_BITS,GET_3_BITS,GET_4_BITS,GET_5_BITS,GET_6_BITS,GET_7_BITS -; Base values. -tempBaseValue: - .byte 3,3,11 +inflateDynamic_tempSymbols: + .byte GET_2_BITS,GET_3_BITS,GET_7_BITS,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15 -; Number of extra bits to read. -tempExtraBits: - .byte 2,3,7 - -; -------------------------------------------------------------------------- -; Arrays for the length and distance codes. - -; Base values. -lengthBaseValue_l: - .byte <3,<4,<5,<6,<7,<8,<9,<10 - .byte <11,<13,<15,<17,<19,<23,<27,<31 - .byte <35,<43,<51,<59,<67,<83,<99,<115 - .byte <131,<163,<195,<227,<258 -distanceBaseValue_l: - .byte <1,<2,<3,<4,<5,<7,<9,<13 - .byte <17,<25,<33,<49,<65,<97,<129,<193 - .byte <257,<385,<513,<769,<1025,<1537,<2049,<3073 - .byte <4097,<6145,<8193,<12289,<16385,<24577 -lengthBaseValue_h: - .byte >3,>4,>5,>6,>7,>8,>9,>10 - .byte >11,>13,>15,>17,>19,>23,>27,>31 - .byte >35,>43,>51,>59,>67,>83,>99,>115 - .byte >131,>163,>195,>227,>258 -distanceBaseValue_h: - .byte >1,>2,>3,>4,>5,>7,>9,>13 - .byte >17,>25,>33,>49,>65,>97,>129,>193 - .byte >257,>385,>513,>769,>1025,>1537,>2049,>3073 - .byte >4097,>6145,>8193,>12289,>16385,>24577 - -; Number of extra bits to read. -lengthExtraBits: - .byte 0,0,0,0,0,0,0,0 - .byte 1,1,1,1,2,2,2,2 - .byte 3,3,3,3,4,4,4,4 - .byte 5,5,5,5,0 -distanceExtraBits: - .byte 0,0,0,0,1,1,2,2 - .byte 3,3,4,4,5,5,6,6 - .byte 7,7,8,8,9,9,10,10 - .byte 11,11,12,12,13,13 +inflateDynamic_headerBits: + .byte GET_4_BITS,GET_5_BITS,GET_5_BITS +inflateDynamic_headerBase: + .byte 3,LENGTH_SYMBOLS,0 ; -------------------------------------------------------------------------- @@ -635,46 +507,28 @@ distanceExtraBits: .bss -; Number of literal codes of each length in the primary tree -; (MAX_BITS bytes, overlap with literalCodeLength). -literalCount: +; Data for building trees. -; -------------------------------------------------------------------------- -; Data for building the primary tree. - -; Lengths of literal codes. -literalCodeLength: +literalSymbolCodeLength: .res 256 -; Length of the end code. -endCodeLength: - .res 1 -; Lengths of length codes. -lengthCodeLength: - .res 29 +controlSymbolCodeLength: + .res CONTROL_SYMBOLS -; -------------------------------------------------------------------------- -; Data for building the distance tree. +; Huffman trees. -; Lengths of distance codes. -distanceCodeLength: - .res 30 -; For two unused codes in the fixed trees and an 'end' mark. - .res 3 +nBitCode_clearFrom: +nBitCode_totalCount: + .res 2*TREE_SIZE +nBitCode_literalCount: + .res TREE_SIZE +nBitCode_controlCount: + .res 2*TREE_SIZE +nBitCode_literalOffset: + .res TREE_SIZE +nBitCode_controlOffset: + .res 2*TREE_SIZE -; -------------------------------------------------------------------------- -; The Huffman trees. - -; Number of codes of each length. -bitsCount: - .res TREES_SIZE -; Pointers to sorted codes of each length. -bitsPointer_l: - .res TREES_SIZE+1 -bitsPointer_h: - .res TREES_SIZE - -; Sorted codes. -sortedCodes: - .res 256+1+29+30+2 - -.endif +codeToLiteralSymbol: + .res 256 +codeToControlSymbol: + .res CONTROL_SYMBOLS From 7e8bb7b700572a50ed4f1e87ebeea4fd35177459 Mon Sep 17 00:00:00 2001 From: Greg King <gregdk@users.sf.net> Date: Sun, 12 Feb 2017 14:54:57 -0500 Subject: [PATCH 29/29] Fixed ca65's BRK instruction encoding for the 65816. BRK is two bytes on all 6502 variants; but, the 65816's maker declared officially that assemblers should support an optional operand. --- src/ca65/instr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ca65/instr.c b/src/ca65/instr.c index 5e7904992..53d3573a6 100644 --- a/src/ca65/instr.c +++ b/src/ca65/instr.c @@ -650,7 +650,7 @@ static const struct { { "BNE", 0x0020000, 0xd0, 0, PutPCRel8 }, { "BPL", 0x0020000, 0x10, 0, PutPCRel8 }, { "BRA", 0x0020000, 0x80, 0, PutPCRel8 }, - { "BRK", 0x0000001, 0x00, 0, PutAll }, + { "BRK", 0x0000005, 0x00, 0, PutAll }, { "BRL", 0x0040000, 0x82, 0, PutPCRel16 }, { "BVC", 0x0020000, 0x50, 0, PutPCRel8 }, { "BVS", 0x0020000, 0x70, 0, PutPCRel8 },