progress
This commit is contained in:
parent
f4773e29ab
commit
4f953e1b3b
|
@ -5,6 +5,24 @@
|
|||
|
||||
.include "CFFA1_API.s"
|
||||
|
||||
.segment "CODERAMSTART"
|
||||
|
||||
jmp quick_note
|
||||
header_text:
|
||||
.byte $d, "VICIOUS CFFA1 MODULE", $d, $0
|
||||
quick_note:
|
||||
clc
|
||||
ldx #0
|
||||
loop: lda header_text, x
|
||||
beq quit
|
||||
jsr $ffef
|
||||
inx
|
||||
jmp loop
|
||||
quit:
|
||||
rts
|
||||
|
||||
|
||||
.code
|
||||
|
||||
_gotoCFFA1:
|
||||
jsr $9006
|
||||
|
|
|
@ -12,6 +12,7 @@ SEGMENTS {
|
|||
LOWCODE: load = ROM, type = ro, optional = yes;
|
||||
INIT: load = ROM, type = ro, define = yes, optional = yes;
|
||||
CODE: load = ROM, type = ro;
|
||||
CODERAMSTART: load = RAMC, type = ro;
|
||||
CODERAM: load = RAMC, type = ro;
|
||||
RODATA: load = ROM, type = ro;
|
||||
DATA: load = ROM, run = RAM, type = rw, define = yes;
|
||||
|
|
|
@ -7,6 +7,20 @@
|
|||
|
||||
byte const CFFA_MODULE_FILENAME[] = { 12, 'V', 'I', 'C', 'I', 'O', 'U', 'S', 'C', 'F', 'F', 'A', '1' };
|
||||
|
||||
byte const CFFA_SIGNATURE[2] = {0xcf, 0xfa};
|
||||
|
||||
byte const MENU_STRING[] =
|
||||
"\r\r VICIOUS MENU (0.9)\r"
|
||||
" ------------------\r"
|
||||
" P - PLAY SID TUNE AT $1000\r"
|
||||
" S - STOP PLAYING\r"
|
||||
" C - CFFA1\r"
|
||||
" L - LOAD & PLAY SID TUNE\r"
|
||||
" A - ABOUT\r"
|
||||
" Q - QUIT\r";
|
||||
|
||||
byte const ABOUT_STRING[] = "\r\rVICIOUS SOUND CARD FOR APPLE-1\rBY SAMPO PELTONEN\rSEARCH GITHUB.COM FOR DOCUMENTATION\r";
|
||||
|
||||
int main (void)
|
||||
{
|
||||
byte keybInput = 0;
|
||||
|
@ -14,16 +28,24 @@ int main (void)
|
|||
initVicilib();
|
||||
|
||||
// is CFFA module loaded?
|
||||
|
||||
// if not, is CFFA card present?
|
||||
|
||||
// if it is, try to load VICIOUSCFFA1
|
||||
POKEW(CFFA1_DESTINATION, 0x7000);
|
||||
POKEW(CFFA1_FILENAME, (word)&CFFA_MODULE_FILENAME[0]);
|
||||
if(callCFFA1API(CFFA1_READFILE)!=0) {
|
||||
prints("\rERROR LOADING CFFA1 MODULE\r");
|
||||
// It is loaded if address $7004 contains "VICIOUS"
|
||||
if(memcmp((byte*)0x7004, (byte*)&CFFA_MODULE_FILENAME[1], 7)) {
|
||||
//prints("\rIS LOADED\r");
|
||||
}
|
||||
else {
|
||||
//prints("\rNOT LOADED\r");
|
||||
|
||||
// if not, is CFFA card present?
|
||||
if(memcmp((byte*)0xAFDC, (byte*)&CFFA_SIGNATURE[0], 2)) {
|
||||
//prints("\rLOADING CFFA MODULE\r");
|
||||
// if it is, try to load VICIOUSCFFA1
|
||||
POKEW(CFFA1_DESTINATION, 0x7000);
|
||||
POKEW(CFFA1_FILENAME, (word)&CFFA_MODULE_FILENAME[0]);
|
||||
if(callCFFA1API(CFFA1_READFILE)!=0) {
|
||||
prints("\rERROR LOADING CFFA1 MODULE\r");
|
||||
}
|
||||
}
|
||||
}
|
||||
while(keybInput!='Q') {
|
||||
prints("\rVICIOUS> ");
|
||||
keybInput = readkey() - 0x80;
|
||||
|
@ -45,12 +67,14 @@ int main (void)
|
|||
playSidFile(0x1000, fileLength);
|
||||
}
|
||||
break;
|
||||
case 'A':
|
||||
prints((byte*)&ABOUT_STRING[0]);
|
||||
break;
|
||||
case 'Q':
|
||||
prints("\rQUIT\r");
|
||||
break;
|
||||
default:
|
||||
prints("\r\r VICIOUS MENU (0.9)\r ------------------\r P - PLAY SID TUNE AT $1000");
|
||||
prints("\r S - STOP PLAYING\r C - CFFA1\r L - LOAD & PLAY SID TUNE\r Q - QUIT\r");
|
||||
prints((byte*)&MENU_STRING[0]);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "sidfile.h"
|
||||
#include "vicilib.h"
|
||||
|
||||
byte const MAGIG_ID_PSID[4] = {'P','S','I','D'};
|
||||
|
||||
void _memcpy(byte* to, word from, word len) {
|
||||
word i=0;
|
||||
|
@ -28,10 +30,13 @@ word _readBigEndianW(word address) {
|
|||
byte readSidHeader(word address, SidHeader1* header1) {
|
||||
header1->location = address;
|
||||
_memcpy((byte*)header1->magicId, address, 4);
|
||||
/*
|
||||
if(header1->magicId[0]!='P' ||
|
||||
header1->magicId[1]!='S' ||
|
||||
header1->magicId[2]!='I' ||
|
||||
header1->magicId[3]!='D') return 0;
|
||||
*/
|
||||
if(memcmp((byte*)&header1->magicId[0], (byte*)&MAGIG_ID_PSID[0], 4)==0) return 0;
|
||||
header1->version = _readBigEndianW(address+4);
|
||||
header1->dataOffset = _readBigEndianW(address+6);
|
||||
header1->loadAddress = _readBigEndianW(address+8);
|
||||
|
|
|
@ -13,15 +13,22 @@
|
|||
.import _prints
|
||||
.import _printw
|
||||
.import _fixSIDTune
|
||||
.import _memcmp
|
||||
.export _playSidFile
|
||||
.export _readSidHeader
|
||||
.export _moveSIDCodeToPlace
|
||||
.export __strcpy
|
||||
.export _MAGIG_ID_PSID
|
||||
.export __memcpy
|
||||
.export __readBigEndianW
|
||||
|
||||
.segment "RODATA"
|
||||
|
||||
_MAGIG_ID_PSID:
|
||||
.byte $50
|
||||
.byte $53
|
||||
.byte $49
|
||||
.byte $44
|
||||
L0001:
|
||||
.byte $0D,$0D,$56,$49,$43,$49,$4F,$55,$53,$20,$53,$49,$44,$20,$50,$4C
|
||||
.byte $41,$59,$45,$52,$0D,$00,$0D,$54,$49,$54,$4C,$45,$3A,$20,$20,$20
|
||||
|
@ -61,7 +68,7 @@ L0001:
|
|||
jsr pushax
|
||||
jsr _readSidHeader
|
||||
tax
|
||||
jeq L0078
|
||||
jeq L007D
|
||||
lda #<(L0001+22)
|
||||
ldx #>(L0001+22)
|
||||
jsr pushax
|
||||
|
@ -159,8 +166,8 @@ L0001:
|
|||
jsr _prints
|
||||
lda #$11
|
||||
sta $BF8E
|
||||
jmp L00BD
|
||||
L0078: lda #<(L0001+177)
|
||||
jmp L00C2
|
||||
L007D: lda #<(L0001+177)
|
||||
ldx #>(L0001+177)
|
||||
jsr pushax
|
||||
jsr _prints
|
||||
|
@ -171,7 +178,7 @@ L0078: lda #<(L0001+177)
|
|||
ldx #>(L0001+210)
|
||||
jsr pushax
|
||||
jsr _prints
|
||||
L00BD: ldy #$7E
|
||||
L00C2: ldy #$7E
|
||||
jmp addysp
|
||||
|
||||
.endproc
|
||||
|
@ -205,37 +212,19 @@ L00BD: ldy #$7E
|
|||
jsr pusha0
|
||||
jsr __memcpy
|
||||
jsr ldax0sp
|
||||
sta ptr1
|
||||
stx ptr1+1
|
||||
ldy #$02
|
||||
lda (ptr1),y
|
||||
cmp #$50
|
||||
bne L0035
|
||||
jsr ldax0sp
|
||||
sta ptr1
|
||||
stx ptr1+1
|
||||
ldy #$03
|
||||
lda (ptr1),y
|
||||
cmp #$53
|
||||
bne L0035
|
||||
jsr ldax0sp
|
||||
sta ptr1
|
||||
stx ptr1+1
|
||||
ldy #$04
|
||||
lda (ptr1),y
|
||||
cmp #$49
|
||||
bne L0035
|
||||
jsr ldax0sp
|
||||
sta ptr1
|
||||
stx ptr1+1
|
||||
ldy #$05
|
||||
lda (ptr1),y
|
||||
cmp #$44
|
||||
beq L0034
|
||||
L0035: ldx #$00
|
||||
txa
|
||||
jsr incax2
|
||||
jsr pushax
|
||||
lda #<(_MAGIG_ID_PSID)
|
||||
ldx #>(_MAGIG_ID_PSID)
|
||||
jsr pushax
|
||||
lda #$04
|
||||
jsr pusha
|
||||
jsr _memcmp
|
||||
cmp #$00
|
||||
bne L0039
|
||||
tax
|
||||
jmp incsp4
|
||||
L0034: jsr pushw0sp
|
||||
L0039: jsr pushw0sp
|
||||
ldy #$05
|
||||
jsr ldaxysp
|
||||
jsr incax4
|
||||
|
@ -382,24 +371,24 @@ L0034: jsr pushw0sp
|
|||
ldy #$0B
|
||||
jsr ldaxidx
|
||||
cpx #$00
|
||||
bne L00C4
|
||||
bne L00C9
|
||||
cmp #$00
|
||||
beq L0064
|
||||
L00C4: ldy #$07
|
||||
beq L0069
|
||||
L00C9: ldy #$07
|
||||
jsr ldaxysp
|
||||
ldy #$0B
|
||||
jsr ldaxidx
|
||||
ldy #$02
|
||||
jsr staxysp
|
||||
jmp L0069
|
||||
L0064: jsr ldax0sp
|
||||
jmp L006E
|
||||
L0069: jsr ldax0sp
|
||||
jsr ldaxi
|
||||
ldy #$02
|
||||
jsr staxysp
|
||||
ldx #$00
|
||||
lda #$02
|
||||
jsr addeq0sp
|
||||
L0069: ldy #$05
|
||||
L006E: ldy #$05
|
||||
jsr pushwysp
|
||||
ldy #$05
|
||||
jsr pushwysp
|
||||
|
@ -423,13 +412,13 @@ L0069: ldy #$05
|
|||
.segment "CODE"
|
||||
|
||||
jsr push0
|
||||
L0014: jsr ldax0sp
|
||||
L0019: jsr ldax0sp
|
||||
ldy #$02
|
||||
cmp (sp),y
|
||||
txa
|
||||
iny
|
||||
sbc (sp),y
|
||||
bcs L0015
|
||||
bcs L001A
|
||||
jsr ldax0sp
|
||||
clc
|
||||
ldy #$04
|
||||
|
@ -445,12 +434,12 @@ L0014: jsr ldax0sp
|
|||
ldy #$00
|
||||
lda (sp),y
|
||||
cmp #$61
|
||||
bcc L001A
|
||||
bcc L001F
|
||||
lda (sp),y
|
||||
sec
|
||||
sbc #$20
|
||||
sta (sp),y
|
||||
L001A: ldy #$02
|
||||
L001F: ldy #$02
|
||||
jsr ldaxysp
|
||||
clc
|
||||
ldy #$07
|
||||
|
@ -469,8 +458,8 @@ L001A: ldy #$02
|
|||
ldy #$01
|
||||
jsr staxysp
|
||||
jsr incsp1
|
||||
jmp L0014
|
||||
L0015: ldy #$09
|
||||
jmp L0019
|
||||
L001A: ldy #$09
|
||||
jsr pushwysp
|
||||
ldy #$05
|
||||
jsr ldaxysp
|
||||
|
@ -496,7 +485,7 @@ L0015: ldy #$09
|
|||
.segment "CODE"
|
||||
|
||||
jsr push0
|
||||
L0009: jsr ldax0sp
|
||||
L000E: jsr ldax0sp
|
||||
ldy #$02
|
||||
cmp (sp),y
|
||||
txa
|
||||
|
@ -527,7 +516,7 @@ L0009: jsr ldax0sp
|
|||
jsr ldax0sp
|
||||
jsr incax1
|
||||
jsr stax0sp
|
||||
jmp L0009
|
||||
jmp L000E
|
||||
|
||||
.endproc
|
||||
|
||||
|
|
|
@ -71,5 +71,7 @@ void fixSIDTune(word address, word len);
|
|||
|
||||
void stopPlaying();
|
||||
|
||||
byte memcmp(byte* a1, byte* a2, byte len);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -82,3 +82,13 @@ void stopPlaying() {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
byte memcmp(byte* a1, byte* a2, byte len) {
|
||||
byte i=0;
|
||||
while(i<len) {
|
||||
if(*(a1+i)!=*(a2+i)) return 0;
|
||||
i++;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue