mirror of
https://github.com/cc65/cc65.git
synced 2025-01-12 17:30:50 +00:00
Correcting some code from github comments
This commit is contained in:
parent
d9778994fa
commit
0e649f24ea
@ -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.
|
||||
|
||||
|
@ -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
|
||||
|
@ -1,9 +1,6 @@
|
||||
SYMBOLS {
|
||||
|
||||
__ORIXHDR__: type = import;
|
||||
|
||||
__STACKSIZE__: type = weak, value = $0800; # 2K stack
|
||||
|
||||
__RAMEND__: type = weak, value = $9800;
|
||||
}
|
||||
MEMORY {
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
||||
|
||||
|
||||
|
@ -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
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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
|
@ -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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user