mirror of
https://github.com/deater/dos33fsprogs.git
synced 2025-02-28 06:30:18 +00:00
pt3: working on auto-generating the tables
This commit is contained in:
parent
2750ba9b13
commit
843b3bd835
@ -2250,3 +2250,133 @@ PT3VolumeTable_35:
|
||||
|
||||
|
||||
pt3_lib_end:
|
||||
|
||||
|
||||
|
||||
; VolTableCreator
|
||||
; based on z80 code by Ivan Roshin
|
||||
; Called with carry==0 for 3.3/3.4 table
|
||||
; Called with carry==1 for 3.5 table
|
||||
|
||||
; 177f-1932 = 435 bytes, not that much better than 512 of lookup
|
||||
|
||||
|
||||
z80_h: .byte $0
|
||||
z80_l: .byte $0
|
||||
z80_d: .byte $0
|
||||
z80_e: .byte $0
|
||||
|
||||
VolTableCreator:
|
||||
lda #$0
|
||||
sta z80_h
|
||||
sta z80_d
|
||||
sta z80_e
|
||||
lda #$11
|
||||
sta z80_l
|
||||
lda #$2A ; ROL for self-modify
|
||||
bcc vol_type1
|
||||
|
||||
lda #$10
|
||||
sta z80_l ; l=16
|
||||
sta z80_e ; e=16
|
||||
|
||||
lda #$ea ; NOP for self modify
|
||||
|
||||
vol_type1:
|
||||
sta vol_smc
|
||||
|
||||
ldy #16 ; skip first row, all zeros
|
||||
ldx #16 ; c=16
|
||||
vol_outer:
|
||||
lda z80_h
|
||||
pha
|
||||
lda z80_l
|
||||
pha ; save HL
|
||||
|
||||
clc ; add HL,DE
|
||||
lda z80_l
|
||||
adc z80_e
|
||||
sta z80_l
|
||||
lda z80_h
|
||||
adc z80_d
|
||||
sta z80_h ; carry is important
|
||||
|
||||
lda z80_h ; ex de,hl ; swap
|
||||
pha
|
||||
lda z80_l
|
||||
pha
|
||||
lda z80_d
|
||||
sta z80_h
|
||||
lda z80_e
|
||||
sta z80_l
|
||||
pla
|
||||
sta z80_e
|
||||
pla
|
||||
sta z80_d
|
||||
|
||||
; sbc hl,hl
|
||||
bcc vol_ffs
|
||||
vol_zeros:
|
||||
lda #0
|
||||
beq vol_write
|
||||
|
||||
vol_ffs:
|
||||
lda #$ff
|
||||
vol_write:
|
||||
sta z80_h
|
||||
sta z80_l
|
||||
|
||||
vol_inner:
|
||||
lda z80_l
|
||||
|
||||
vol_smc:
|
||||
nop ; nop or ROL depending
|
||||
|
||||
lda z80_h
|
||||
|
||||
adc #$0 ; a=a+carry;
|
||||
|
||||
sta VolumeTable,Y
|
||||
iny
|
||||
|
||||
clc ; add HL,DE
|
||||
lda z80_l
|
||||
adc z80_e
|
||||
sta z80_l
|
||||
lda z80_h
|
||||
adc z80_d
|
||||
sta z80_h
|
||||
|
||||
inx ; inc C
|
||||
txa ; a=c
|
||||
and #$f
|
||||
bne vol_inner
|
||||
|
||||
|
||||
pla
|
||||
sta z80_l
|
||||
pla
|
||||
sta z80_h ; restore HL
|
||||
|
||||
lda z80_e ; a=e
|
||||
cmp #$77
|
||||
bne vol_m3
|
||||
|
||||
inc z80_e
|
||||
bne vol_blah
|
||||
inc z80_d
|
||||
vol_blah:
|
||||
|
||||
vol_m3:
|
||||
txa ; a=c
|
||||
;bne vol_outer
|
||||
beq vol_done
|
||||
jmp vol_outer
|
||||
|
||||
vol_done:
|
||||
rts
|
||||
|
||||
|
||||
|
||||
VolumeTable:
|
||||
.res 256,0
|
||||
|
204
pt3_player/table_gen/6502_table.c
Normal file
204
pt3_player/table_gen/6502_table.c
Normal file
@ -0,0 +1,204 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
static unsigned char PT3VolumeTable_33_34[]={
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, //0
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1, //1
|
||||
0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x1,0x1,0x1,0x1,0x2,0x2,0x2,0x2,0x2, //2
|
||||
0x0,0x0,0x0,0x0,0x1,0x1,0x1,0x1,0x2,0x2,0x2,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,
|
||||
};
|
||||
|
||||
|
||||
static unsigned char VT[256];
|
||||
|
||||
//VolTableCreator (c) Ivan Roshin
|
||||
//A - VersionForVolumeTable (0..4 - 3.xx..3.4x;
|
||||
//5.. - 3.5x..3.6x..VTII1.0)
|
||||
|
||||
void VolTableCreator(int which) {
|
||||
|
||||
unsigned char a,c,carry,old_carry;
|
||||
unsigned short hl,de,ix;
|
||||
unsigned short s[16];
|
||||
unsigned int temp1,temp2;
|
||||
int self_modified=0;
|
||||
|
||||
//cp 005h ; compare accumulator with 5?
|
||||
|
||||
carry=which;
|
||||
|
||||
hl=0x11;
|
||||
de=0x00;
|
||||
a=0x17; //ld a,017h RLA ; a=$17
|
||||
if (!carry) goto m1; //jr nc,m1 ; if (carry==1) {
|
||||
hl--; //dec l ; l--;
|
||||
de=hl; //ld e,l ; e=l;
|
||||
a=0; //xor a ; a=a^a; (a=0?)
|
||||
self_modified=1;
|
||||
m1: // ; }
|
||||
// ld (m2),a set m2 to NOP (0) or RLA ($17)
|
||||
ix=16; //ld ix,VT_+16 ; IX is 16 entries into table (
|
||||
c=0x10; //ld c,010h ; c=16
|
||||
pt3_initv2:
|
||||
printf("1: HL=%04X DE=%04X\n",hl,de);
|
||||
s[0]=hl; // push hl ; save hl
|
||||
|
||||
// add hl,de ; hl=hl+de
|
||||
temp1=hl;
|
||||
temp2=de;
|
||||
temp1=temp1+temp2;
|
||||
hl=temp1&0xffff;
|
||||
// if (temp1&(1<<16)) carry=1;
|
||||
// else carry=0;
|
||||
|
||||
printf("2: HL=%04X DE=%04X\n",hl,de);
|
||||
|
||||
// ex de,hl ; swap
|
||||
temp1=hl;
|
||||
hl=de;
|
||||
de=temp1;
|
||||
|
||||
printf("3: HL=%04X DE=%04X\n",hl,de);
|
||||
|
||||
// sbc hl,hl
|
||||
if (carry==0) hl=0x0;
|
||||
else hl=0xffff;
|
||||
|
||||
pt3_initv1:
|
||||
a=hl&0xff; // ld a,l 7d ; ?
|
||||
//m2:
|
||||
// Self modified, RLA or NOP depending
|
||||
// ld a,l 7d 00=nop ; this is self modified
|
||||
if (self_modified) {
|
||||
/* nop */
|
||||
}
|
||||
else {
|
||||
/* rla $17 */
|
||||
old_carry=carry;
|
||||
carry=!!(a&0x80);
|
||||
a=a<<1;
|
||||
a|=old_carry;
|
||||
}
|
||||
|
||||
a=hl>>8; // ld a,h 7c ; ?
|
||||
// adc a,000h
|
||||
a=a+carry;
|
||||
|
||||
VT[ix]=a;//ld (ix+000h),a
|
||||
ix++; // inc ix
|
||||
|
||||
// add hl,de
|
||||
temp1=hl;
|
||||
temp2=de;
|
||||
temp1=temp1+temp2;
|
||||
hl=temp1;
|
||||
|
||||
// printf("4: HL=%04X DE=%04X\n",hl,de);
|
||||
|
||||
c++; // inc c
|
||||
a=c; // ld a,c
|
||||
a=a&0xf;// and 00fh
|
||||
if (a!=0) goto pt3_initv1; // jr nz,pt3_initv1
|
||||
hl=s[0];
|
||||
a=de&0xff; // ld a,e
|
||||
// cp 077h
|
||||
// jr nz,m3
|
||||
if ((a-0x77)!=0) goto m3;
|
||||
de++; //inc e
|
||||
m3:
|
||||
a=c; // ld a,c
|
||||
a=a&a; // and a
|
||||
if (a!=0) goto pt3_initv2; // jr nz,pt3_initv2
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
int i;
|
||||
|
||||
VolTableCreator(0);
|
||||
|
||||
for(i=0;i<256;i++) {
|
||||
if (i%16==0) printf("\n");
|
||||
printf(" %02X",VT[i]);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
if (!memcmp(VT,PT3VolumeTable_35,256)) {
|
||||
printf("MATCH 35\n");
|
||||
}
|
||||
else {
|
||||
printf("NO MATCH 35\n");
|
||||
}
|
||||
|
||||
if (!memcmp(VT,PT3VolumeTable_33_34,256)) {
|
||||
printf("MATCH 34\n");
|
||||
}
|
||||
else {
|
||||
printf("NO MATCH 34\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
VolTableCreator(1);
|
||||
|
||||
for(i=0;i<256;i++) {
|
||||
if (i%16==0) printf("\n");
|
||||
printf(" %02X",VT[i]);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
if (!memcmp(VT,PT3VolumeTable_35,256)) {
|
||||
printf("MATCH 35\n");
|
||||
}
|
||||
else {
|
||||
printf("NO MATCH 35\n");
|
||||
}
|
||||
|
||||
if (!memcmp(VT,PT3VolumeTable_33_34,256)) {
|
||||
printf("MATCH 34\n");
|
||||
}
|
||||
else {
|
||||
printf("NO MATCH 34\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user