mirror of
https://github.com/deater/dos33fsprogs.git
synced 2025-02-05 21:34:30 +00:00
pt3: messing around with code to autogen some of the tables
This commit is contained in:
parent
acc8c3f0fb
commit
2cc79ed73c
304
pt3_player/table_gen/table_gen.c
Normal file
304
pt3_player/table_gen/table_gen.c
Normal file
@ -0,0 +1,304 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static unsigned char out[256];
|
||||
|
||||
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,0x2,0x3,0x3,0x3,0x3, //3
|
||||
0x0,0x0,0x0,0x0,0x1,0x1,0x1,0x2,0x2,0x2,0x3,0x3,0x3,0x4,0x4,0x4, //4
|
||||
0x0,0x0,0x0,0x1,0x1,0x1,0x2,0x2,0x3,0x3,0x3,0x4,0x4,0x4,0x5,0x5, //5
|
||||
0x0,0x0,0x0,0x1,0x1,0x2,0x2,0x3,0x3,0x3,0x4,0x4,0x5,0x5,0x6,0x6, //6
|
||||
0x0,0x0,0x1,0x1,0x2,0x2,0x3,0x3,0x4,0x4,0x5,0x5,0x6,0x6,0x7,0x7, //7
|
||||
0x0,0x0,0x1,0x1,0x2,0x2,0x3,0x3,0x4,0x5,0x5,0x6,0x6,0x7,0x7,0x8, //8
|
||||
0x0,0x0,0x1,0x1,0x2,0x3,0x3,0x4,0x5,0x5,0x6,0x6,0x7,0x8,0x8,0x9, //9
|
||||
0x0,0x0,0x1,0x2,0x2,0x3,0x4,0x4,0x5,0x6,0x6,0x7,0x8,0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5,0x6,0x6,0x7,0x7,0x8,
|
||||
0x0,0x1,0x1,0x2,0x2,0x3,0x4,0x4,0x5,0x5,0x6,0x7,0x7,0x8,0x8,0x9,
|
||||
0x0,0x1,0x1,0x2,0x3,0x3,0x4,0x5,0x5,0x6,0x7,0x7,0x8,0x9,0x9,0xA,
|
||||
0x0,0x1,0x1,0x2,0x3,0x4,0x4,0x5,0x6,0x7,0x7,0x8,0x9,0xA,0xA,0xB,
|
||||
0x0,0x1,0x2,0x2,0x3,0x4,0x5,0x6,0x6,0x7,0x8,0x9,0xA,0xA,0xB,0xC,
|
||||
0x0,0x1,0x2,0x3,0x3,0x4,0x5,0x6,0x7,0x8,0x9,0xA,0xA,0xB,0xC,0xD,
|
||||
0x0,0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x7,0x8,0x9,0xA,0xB,0xC,0xD,0xE,
|
||||
0x0,0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x8,0x9,0xA,0xB,0xC,0xD,0xE,0xF,
|
||||
};
|
||||
|
||||
static unsigned char gen1[]={
|
||||
// 16 0
|
||||
0xf0,
|
||||
// 8 0,8 1
|
||||
0x70,0x71,
|
||||
// 6 0,5 1,5 2
|
||||
0x50,0x41,0x42,
|
||||
// 4 0,4 1,4 2,4 3
|
||||
0x30,0x31,0x32,0x33,
|
||||
// 4 0,3 1,3 2,3 3,3 4
|
||||
0x30,0x21,0x22,0x23,0x24,
|
||||
// 3 0,3 1,2 2,3 3,3 4,2 5
|
||||
0x20,0x21,0x12,0x23,0x24,0x15,
|
||||
// 3 0,2 1,2 2,3 3,2 4,2 5,2 6
|
||||
0x20,0x11,0x12,0x23,0x14,0x15,0x16,
|
||||
// 2 0,2 1,2 2,2 3,2 4,2 5,2 6,2 7
|
||||
0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
|
||||
// 2 0,2 1,2 2,2 3,1 4,2 5,2 6,2 7,1 8
|
||||
0x10,0x11,0x12,0x13,0x04,0x15,0x16,0x17,0x08,
|
||||
// 2 0,2 1,1 2,2 3,1 4,2 5,2 6,1 7,2 8,1 9
|
||||
0x10,0x11,0x02,0x13,0x04,0x15,0x16,0x07,0x18,0x09,
|
||||
// 2 0,1 1,2 2,1 3,2 4,1 5,2 6,1 7,2 8,1 9,1 A
|
||||
0x10,0x01,0x12,0x03,0x14,0x05,0x16,0x07,0x18,0x09,0x0a,
|
||||
// 2 0,1 1,1 2,2 3,1 4,1 5,2 6,1 7,1 8,2 9,1 A,1 B
|
||||
0x10,0x01,0x02,0x13,0x04,0x05,0x16,0x07,0x08,0x19,0x0a,0x0b,
|
||||
// 2 0,1 1,1 2,1 3,2 4,1 5,1 6,1 7,2 8,1 9,1 A,1 B,1 C
|
||||
0x10,0x01,0x02,0x03,0x14,0x05,0x06,0x07,0x18,0x09,0x0a,0x0b,0x0c,
|
||||
// 2 0,1 1,1 2,1 3,1 4,1 5,1 6,2 7,1 8,1 9,1 A,1 B,1 C,1 D
|
||||
0x10,0x01,0x02,0x03,0x04,0x05,0x06,0x17,0x08,0x09,0x0a,0x0b,0x0c,0x0d,
|
||||
// 2 0,1 1,1 2,1 3,1 4,1 5,1 6,1 7,1 8,1 9,1 A,1 B,1 C,1 D,1 E
|
||||
0x10,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,
|
||||
// 1 0,1 1,1 2,1 3,1 4,1 5,1 6,1 7,1 8,1 9,1 A,1 B,1 C,1 D,1 E,1 F
|
||||
0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
|
||||
};
|
||||
|
||||
static void gen_table_1(void) {
|
||||
int total=0,temp,index=0,i;
|
||||
|
||||
while(total<256) {
|
||||
temp=gen1[index];
|
||||
for(i=0;i<(temp>>4)+1;i++) {
|
||||
out[total]=temp&0xf;
|
||||
total++;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static unsigned char gen2[]={
|
||||
// 16 0 SKIP this always 0
|
||||
|
||||
// 8 0,8 1
|
||||
// 770 = 111 1,11 00
|
||||
0xfc,
|
||||
// 6 0,5 1,5 2
|
||||
// 544 = 101 1,00 00 -- 400 = 100,0 0000
|
||||
0xb0,0x80,
|
||||
// 4 0,4 1,4 2,4 3
|
||||
// 330 330 = 011 0,11 00 011 0,11 00
|
||||
0x6c,0x6c,
|
||||
// 4 0,3 1,3 2,3 3,3 4
|
||||
// 323 220 = 0110,1011 0100,1000
|
||||
0x6b,0x48,
|
||||
// 3 0,3 1,2 2,3 3,3 4,2 5
|
||||
// 222 222 = 010 0,10 10 010 0,10 10
|
||||
0x4a,0x4a,
|
||||
// 3 0,2 1,2 2,3 3,2 4,2 5,2 6
|
||||
// 212 212 100 = 010 0,01 10 010 0,10 01 00100000
|
||||
0x46,0x46,0x20,
|
||||
// 2 0,2 1,2 2,2 3,2 4,2 5,2 6,2 7
|
||||
// 112 112 110 = 0010,0110 0010,0110 0010,01 00
|
||||
0x26,0x26,0x24,
|
||||
// 2 0,2 1,2 2,2 3,1 4,2 5,2 6,2 7,1 8
|
||||
// 112 102 111 - 0010,0110 0010,0010 0010,0101
|
||||
0x26,0x22,0x25,
|
||||
// 2 0,2 1,1 2,2 3,1 4,2 5,2 6,1 7,2 8,1 9
|
||||
// 111 102 102 000 = 0010,0101 0010,0010 0010,0010 0000,0000
|
||||
0x25,0x22,0x22,0x00,
|
||||
// 2 0,1 1,2 2,1 3,2 4,1 5,2 6,1 7,2 8,1 9,1 A
|
||||
// 102 011 102 000 - 0010,0010 0000,0101 0010,0010 0000,0000
|
||||
0x22,0x05,0x22,0x00,
|
||||
// 2 0,1 1,1 2, 2 3,1 4,1 5, 2 6,1 7,1 8, 2 9,1 A,1 B
|
||||
// 101 101 101 101 = 0010,0001
|
||||
0x21,0x21,0x21,0x21,
|
||||
// 2 0,1 1,1 2, 1 3,2 4,1 5, 1 6,1 7,2 8, 1 9,1 A,1 B, 1 C
|
||||
// 101 011 002 001 000 = 0010,0001 0000,0101 0000,0010 0000,0001 0000,0000
|
||||
0x21,0x05,0x02,0x01,0x00,
|
||||
// 2 0,1 1,1 2, 1 3,1 4,1 5, 1 6,2 7,1 8, 1 9,1 A,1 B, 1 C,1 D
|
||||
// 101 001 011 001 000 = 0010,0001 0000,0001 0000,0101 0000,0001 0000,0000
|
||||
0x21,0x01,0x05,0x1,0x0,
|
||||
// 2 0,1 1,1 2,1 3,1 4,1 5,1 6,1 7,1 8,1 9,1 A,1 B,1 C,1 D,1 E
|
||||
// 101 001 001 001 001 000 = 001 0,00 01 000 000 01
|
||||
0x21,0x01,0x01,0x01,0x01,0x00,
|
||||
// 1 0,1 1,1 2,1 3,1 4,1 5,1 6,1 7,1 8,1 9,1 A,1 B,1 C,1 D,1 E,1 F
|
||||
// 001 001 001 001 001 000 = 000 000 01
|
||||
0x01,0x01,0x01,0x01,0x01,0x00,
|
||||
};
|
||||
|
||||
|
||||
static unsigned char gen3[]={
|
||||
// 16 0 SKIP this always 0
|
||||
|
||||
|
||||
// 8 0,8 1
|
||||
// 770 = 111 1,11 00
|
||||
0xfc,
|
||||
// 4 0,8 1,4 2
|
||||
// 370 300 = 011 1,11 00 -- 011,0 0000
|
||||
0x7c,0x60,
|
||||
// 3 0,5 1,5 2, 3 3
|
||||
// 240 420 = 0101,000 1000,1000
|
||||
0x50,0x88,
|
||||
// 2 0,4 1, 4 2,4 3,2 4
|
||||
// 130 332 = 0010,1100, 0110,1110
|
||||
0x2c,0x6e,
|
||||
// 2 0,3 1,3 2, 3 3,3 4,2 5
|
||||
// 123 222 = 001 0,10 11 010 0,10 10
|
||||
0x2b,0x4a,
|
||||
// 2 0,2 1,3 2, 2 3,3 4,2 5, 2 6
|
||||
// 113 122 100 = 001 0,01 11 001 0,10 10 00100000
|
||||
0x27,0x2a,0x20,
|
||||
// 2 0,2 1,2 2,2 3,2 4,2 5,2 6,2 7
|
||||
// 112 112 110 = 0010,0110 0010,0110 0010,01 00
|
||||
0x26,0x26,0x24,
|
||||
// 1 0,2 1,2 2, 2 3,2 4,2 5, 2 6,2 7,1 8
|
||||
// 012 112 111 - 0000,0110 0010,0110 0010,0101
|
||||
0x06,0x26,0x25,
|
||||
// 1 0,2 1,2 2, 1 3,2 4,2 5, 1 6,2 7,2 8, 1 9
|
||||
// 012 012 012 000 = 0000,0110 0000,0000
|
||||
0x06,0x06,0x06,0x00,
|
||||
// 1 0,2 1,1 2, 2 3,1 4,2 5, 1 6,2 7,1 8, 2 9,1 A
|
||||
// 011 102 011 100 - 0000,0101 0010,0010 0010,0010 0010,0000
|
||||
0x05,0x22,0x05,0x20,
|
||||
// 1 0,2 1,1 2, 1 3,2 4,1 5, 1 6,2 7,1 8, 1 9,2 A,1 B
|
||||
// 011 111 011 011 = 0000,0101
|
||||
0x05,0x05,0x05,0x05,
|
||||
// 1 0,1 1,2 2, 1 3,1 4,1 5, 2 6,1 7,1 8, 1 9,2 A,1 B, 1 C
|
||||
// 002 001 101 011 000 = 0000,0010 0000,0001 0010,0001 0000,0101 0000,0000
|
||||
0x02,0x01,0x21,0x05,0x00,
|
||||
// 1 0,1 1,1 2, 2 3,1 4,1 5, 1 6,1 7,1 8, 1 9,2 A,1 B, 1 C,1 D
|
||||
// 001 101 001 011 000 = 0010,0001 0000,0001 0000,0101 0000,0001 0000,0000
|
||||
0x01,0x21,0x01,0x05,0x00,
|
||||
// 1 0,1 1,1 2, 1 3,1 4,1 5, 1 6,2 7,1 8, 1 9,1 A,1 B, 1 C,1 D,1 E
|
||||
// 001 001 011 001 001 000 = 001 0,00 01 000 000 01
|
||||
0x01,0x01,0x05,0x01,0x01,0x01,
|
||||
|
||||
// 1 0,1 1,1 2,1 3,1 4,1 5,1 6,1 7,1 8,1 9,1 A,1 B,1 C,1 D,1 E,1 F
|
||||
// 001 001 001 001 001 000 = 000 000 01
|
||||
0x01,0x01,0x01,0x01,0x01,0x00,
|
||||
};
|
||||
|
||||
static void gen_table_2(unsigned char *g) {
|
||||
|
||||
int row=0,column=0,val,index=0,temp,i,total=0;
|
||||
|
||||
while(row<15) {
|
||||
val=0;
|
||||
column=0;
|
||||
printf("\n");
|
||||
while(1) {
|
||||
temp=(g[index]>>5)&0x7;
|
||||
for(i=0;i<temp+1;i++) {
|
||||
out[16+total]=val;
|
||||
printf("%x ",val);
|
||||
total++;
|
||||
column++;
|
||||
}
|
||||
|
||||
if (column>=16) break;
|
||||
|
||||
val++;
|
||||
temp=(g[index]>>2)&0x7;
|
||||
for(i=0;i<temp+1;i++) {
|
||||
out[16+total]=val;
|
||||
printf("%x ",val);
|
||||
total++;
|
||||
column++;
|
||||
}
|
||||
|
||||
if (column>=16) break;
|
||||
|
||||
temp=(g[index])&0x3;
|
||||
if (temp!=0) {
|
||||
val++;
|
||||
for(i=0;i<temp;i++) {
|
||||
out[16+total]=val;
|
||||
printf("%x ",val);
|
||||
total++;
|
||||
column++;
|
||||
}
|
||||
}
|
||||
val++;
|
||||
if (column>=16) break;
|
||||
index++;
|
||||
}
|
||||
index++;
|
||||
|
||||
row++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
|
||||
|
||||
int i;
|
||||
|
||||
printf("Default is 256 bytes!\n");
|
||||
|
||||
|
||||
printf("\nNext is %ld bytes\n",sizeof(gen1));
|
||||
memset(out,0,256);
|
||||
gen_table_1();
|
||||
|
||||
for(i=0;i<256;i++) {
|
||||
if (out[i]!=PT3VolumeTable_33_34[i]) {
|
||||
fprintf(stderr,"Mismatch at %d (%x) expected %d got %d!\n",
|
||||
i,i,PT3VolumeTable_33_34[i],out[i]);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
printf("\nNext is %ld bytes\n",sizeof(gen2));
|
||||
memset(out,0,256);
|
||||
gen_table_2(gen2);
|
||||
|
||||
for(i=0;i<256;i++) {
|
||||
if (out[i]!=PT3VolumeTable_33_34[i]) {
|
||||
fprintf(stderr,"Mismatch at %d (%x) expected %d got %d!\n",
|
||||
i,i,PT3VolumeTable_33_34[i],out[i]);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
printf("\nGNext is %ld bytes\n",sizeof(gen3));
|
||||
memset(out,0,256);
|
||||
gen_table_2(gen3);
|
||||
|
||||
for(i=0;i<256;i++) {
|
||||
if (out[i]!=PT3VolumeTable_35[i]) {
|
||||
fprintf(stderr,"Mismatch at %d (%x) expected %d got %d!\n",
|
||||
i,i,PT3VolumeTable_35[i],out[i]);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
211
pt3_player/table_gen/z80_table.c
Normal file
211
pt3_player/table_gen/z80_table.c
Normal file
@ -0,0 +1,211 @@
|
||||
#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,0x2,0x3,0x3,0x3,0x3, //3
|
||||
0x0,0x0,0x0,0x0,0x1,0x1,0x1,0x2,0x2,0x2,0x3,0x3,0x3,0x4,0x4,0x4, //4
|
||||
0x0,0x0,0x0,0x1,0x1,0x1,0x2,0x2,0x3,0x3,0x3,0x4,0x4,0x4,0x5,0x5, //5
|
||||
0x0,0x0,0x0,0x1,0x1,0x2,0x2,0x3,0x3,0x3,0x4,0x4,0x5,0x5,0x6,0x6, //6
|
||||
0x0,0x0,0x1,0x1,0x2,0x2,0x3,0x3,0x4,0x4,0x5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2,0x2,0x3,0x3,0x3,0x4,0x4,0x4,0x5,0x5,
|
||||
0x0,0x0,0x1,0x1,0x2,0x2,0x2,0x3,0x3,0x4,0x4,0x4,0x5,0x5,0x6,0x6,
|
||||
0x0,0x0,0x1,0x1,0x2,0x2,0x3,0x3,0x4,0x4,0x5,0x5,0x6,0x6,0x7,0x7,
|
||||
0x0,0x1,0x1,0x2,0x2,0x3,0x3,0x4,0x4,0x5,0x5,0x6,0x6,0x7,0x7,0x8,
|
||||
0x0,0x1,0x1,0x2,0x2,0x3,0x4,0x4,0x5,0x5,0x6,0x7,0x7,0x8,0x8,0x9,
|
||||
0x0,0x1,0x1,0x2,0x3,0x3,0x4,0x5,0x5,0x6,0x7,0x7,0x8,0x9,0x9,0xA,
|
||||
0x0,0x1,0x1,0x2,0x3,0x4,0x4,0x5,0x6,0x7,0x7,0x8,0x9,0xA,0xA,0xB,
|
||||
0x0,0x1,0x2,0x2,0x3,0x4,0x5,0x6,0x6,0x7,0x8,0x9,0xA,0xA,0xB,0xC,
|
||||
0x0,0x1,0x2,0x3,0x3,0x4,0x5,0x6,0x7,0x8,0x9,0xA,0xA,0xB,0xC,0xD,
|
||||
0x0,0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x7,0x8,0x9,0xA,0xB,0xC,0xD,0xE,
|
||||
0x0,0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x8,0x9,0xA,0xB,0xC,0xD,0xE,0xF,
|
||||
};
|
||||
|
||||
|
||||
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 h,l,d,e,a,c,carry,old_carry;
|
||||
unsigned short ix;
|
||||
unsigned char s[16];
|
||||
unsigned int temp1,temp2;
|
||||
int self_modified=0;
|
||||
|
||||
//cp 005h ; compare accumulator with 5?
|
||||
|
||||
carry=which;
|
||||
|
||||
h=0; //ld hl,00011h ; load 16-bit value at address $11 to hl?
|
||||
l=0x11; // ; does not affect flags
|
||||
d=h; //ld d,h ; d=h
|
||||
e=h; //ld e,h ; e=h
|
||||
a=0x17; //ld a,017h RLA ; a=$17
|
||||
if (!carry) goto m1; //jr nc,m1 ; if (carry==1) {
|
||||
l--; //dec l ; l--;
|
||||
e=l; //ld e,l ; e=l;
|
||||
a=a^a; //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:
|
||||
s[0]=h;
|
||||
s[1]=l; // push hl ; save hl
|
||||
|
||||
// add hl,de ; hl=hl+de
|
||||
temp1=(h<<8)|l;
|
||||
temp2=(d<<8)|e;
|
||||
temp1=temp1+temp2;
|
||||
h=(temp1>>8)&0xff;
|
||||
l=temp1&0xff;
|
||||
if (temp1&(1<<16)) carry=1;
|
||||
else carry=0;
|
||||
|
||||
// ex de,hl ; swap
|
||||
temp1=(h<<8)|l;
|
||||
temp2=(d<<8)|e;
|
||||
h=(temp2>>8);
|
||||
l=temp2&0xff;
|
||||
d=(temp1>>8);
|
||||
e=temp1&0xff;
|
||||
|
||||
// sbc hl,hl
|
||||
// temp1=(h<<8)|l;
|
||||
// temp2=(h<<8)|l;
|
||||
// temp1=temp1-temp2-carry;
|
||||
// h=(temp1>>8);
|
||||
// l=temp1&0xff;
|
||||
if (carry==0) { h=0; l=0;}
|
||||
else {h=0xff; l=0xff;}
|
||||
|
||||
pt3_initv1:
|
||||
a=l; // 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=h; // ld a,h 7c ; ?
|
||||
// adc a,000h
|
||||
a=a+carry;
|
||||
|
||||
VT[ix]=a;//ld (ix+000h),a
|
||||
ix++; // inc ix
|
||||
|
||||
// add hl,de
|
||||
temp1=(h<<8)|l;
|
||||
temp2=(d<<8)|e;
|
||||
temp1=temp1+temp2;
|
||||
h=(temp1>>8);
|
||||
l=temp1&0xff;
|
||||
|
||||
c++; // inc c
|
||||
a=c; // ld a,c
|
||||
a=a&0xf;// and 00fh
|
||||
if (a!=0) goto pt3_initv1; // jr nz,pt3_initv1
|
||||
h=s[0];
|
||||
l=s[1]; // pop hl
|
||||
a=e; // ld a,e
|
||||
// cp 077h
|
||||
// jr nz,m3
|
||||
if ((a-0x77)!=0) goto m3;
|
||||
e++; //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