peasant: change up how generate_common symbol extraction works

more scriptable in Makefile
This commit is contained in:
Vince Weaver 2021-09-26 00:46:35 -04:00
parent dc865e888b
commit ec44509313
2 changed files with 40 additions and 48 deletions

View File

@ -78,7 +78,14 @@ generate_common.o: generate_common.c
####
music.inc: generate_common MUSIC
./generate_common > music.inc
./generate_common -a 0xd000 -s pt3_init_song music.lst > music.inc
./generate_common -a 0xd000 -s mockingboard_init music.lst >> music.inc
./generate_common -a 0xd000 -s reset_ay_both music.lst >> music.inc
./generate_common -a 0xd000 -s clear_ay_both music.lst >> music.inc
./generate_common -a 0xd000 -s mockingboard_setup_interrupt music.lst >> music.inc
./generate_common -a 0xd000 -s mockingboard_disable_interrupt music.lst >> music.inc
./generate_common -a 0xd000 -s done_pt3_irq_handler music.lst >> music.inc
./generate_common -a 0xd000 -s PT3_LOC music.lst >> music.inc
###
@ -311,3 +318,5 @@ clean:
PEASANT1 PEASANT2 PEASANT3 PEASANT4 \
TROGDOR ENDING MUSIC

View File

@ -1,21 +1,21 @@
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
/* music */
static char filename[]="music.lst";
static int routine_offset=0xD000;
static FILE *fff;
static void find_address(char *symbol_name) {
static void find_address(char *symbol_name, int routine_offset) {
unsigned int addr=0;
char string[BUFSIZ],*result;
char temp_name[BUFSIZ];
sprintf(temp_name,"%s:",symbol_name);
strncpy(temp_name,symbol_name,BUFSIZ);
strncat(temp_name,":",2);
while(1) {
@ -36,54 +36,37 @@ static void find_address(char *symbol_name) {
int main(int argc, char **argv) {
int c;
char *filename;
char symbol[BUFSIZ];
int routine_offset=0xd000;
while ( (c=getopt(argc, argv, "a:s:") ) != -1) {
switch(c) {
case 'a':
routine_offset=strtol(optarg, NULL, 0);
break;
case 's':
strncpy(symbol,optarg,BUFSIZ-1);
break;
default:
fprintf(stderr,"Unknown option %c\n",c);
exit(-1);
break;
}
}
filename=strdup(argv[optind]);
fff=fopen(filename,"r");
if (fff==NULL) {
fprintf(stderr,"ERROR! could not open %s\n",filename);
return -1;
}
printf(";=============================\n");
printf("; external routines\n");
printf("\n");
// printf("; loader.s\n");
// find_address("opendir_filename");
// printf("\n");
// printf("; audio.s\n");
// find_address("play_audio");
// printf("\n");
printf(";\n");
find_address("pt3_init_song");
printf("\n");
printf(";\n");
find_address("mockingboard_init");
printf("\n");
printf(";\n");
find_address("reset_ay_both");
printf("\n");
printf(";\n");
find_address("clear_ay_both");
printf("\n");
printf(";\n");
find_address("mockingboard_setup_interrupt");
printf("\n");
printf(";\n");
find_address("mockingboard_disable_interrupt");
printf("\n");
printf(";\n");
find_address("done_pt3_irq_handler");
printf("\n");
printf(";\n");
find_address("PT3_LOC");
find_address(symbol,routine_offset);
printf("\n");
fclose(fff);