From: Lukas Krickl Date: Wed, 22 Mar 2023 05:26:43 +0000 (+0100) Subject: Added more rooms X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=8aeb44f65251bb7cc1a218e3b7403abe8f0e1685;p=turtlebay%2F.git Added more rooms --- diff --git a/gfx/room01_pf0.png b/gfx/room01_pf0.png new file mode 100644 index 0000000..8ca1616 Binary files /dev/null and b/gfx/room01_pf0.png differ diff --git a/gfx/room01_pf0.spr b/gfx/room01_pf0.spr new file mode 100644 index 0000000..edb6935 --- /dev/null +++ b/gfx/room01_pf0.spr @@ -0,0 +1,26 @@ +; Sprite of ../../gfx/room01_pf0.png +.byte %000001111 +.byte %000000001 +.byte %000000001 +.byte %000000001 +.byte %000111001 +.byte %000001001 +.byte %000001001 +.byte %000000001 +.byte %000000001 +.byte %000000001 +.byte %010001001 +.byte %010001001 +.byte %000000001 +.byte %000000001 +.byte %000000001 +.byte %000001001 +.byte %000001001 +.byte %000111001 +.byte %000000001 +.byte %000000001 +.byte %000000001 +.byte %000000001 +.byte %000000001 +.byte %000001111 + diff --git a/gfx/room01_pf1.png b/gfx/room01_pf1.png new file mode 100644 index 0000000..f9db4f7 Binary files /dev/null and b/gfx/room01_pf1.png differ diff --git a/gfx/room01_pf1.spr b/gfx/room01_pf1.spr new file mode 100644 index 0000000..957740c --- /dev/null +++ b/gfx/room01_pf1.spr @@ -0,0 +1,26 @@ +; Sprite of ../../gfx/room01_pf1.png +.byte %00000000 +.byte %00000000 +.byte %00000000 +.byte %00000000 +.byte %00111110 +.byte %00000010 +.byte %00000010 +.byte %00000010 +.byte %00000010 +.byte %00000010 +.byte %11111110 +.byte %11111110 +.byte %00000010 +.byte %00000010 +.byte %00000010 +.byte %00000010 +.byte %00000010 +.byte %00111110 +.byte %00000000 +.byte %00000000 +.byte %00000000 +.byte %00000000 +.byte %00000000 +.byte %00000000 + diff --git a/gfx/room01_pf2.png b/gfx/room01_pf2.png new file mode 100644 index 0000000..5453245 Binary files /dev/null and b/gfx/room01_pf2.png differ diff --git a/gfx/room01_pf2.spr b/gfx/room01_pf2.spr new file mode 100644 index 0000000..da32378 --- /dev/null +++ b/gfx/room01_pf2.spr @@ -0,0 +1,26 @@ +; Sprite of ../../gfx/room01_pf2.png +.byte %00000000 +.byte %00000000 +.byte %00111110 +.byte %00100000 +.byte %00100000 +.byte %00100000 +.byte %00100000 +.byte %00100000 +.byte %00100000 +.byte %00100000 +.byte %00100000 +.byte %00100000 +.byte %00100000 +.byte %00100000 +.byte %00100000 +.byte %00100000 +.byte %00100000 +.byte %00100000 +.byte %00100000 +.byte %00111110 +.byte %00000000 +.byte %00000000 +.byte %00000000 +.byte %00000000 + diff --git a/main.asm b/main.asm index 007a6ef..e8c43bb 100644 --- a/main.asm +++ b/main.asm @@ -99,7 +99,7 @@ P1STARTX = 0 P1STARTY = 0 M0HEIGHT = 4 M0RESPAWNT = 255 -MAPCOUNT = 0 +MAPCOUNT = 1 OFFSETPERMAP = 6 ;=============================================================================== @@ -556,6 +556,7 @@ GameProgress jmp ProgressDone NextMapProg jsr NextMap + jsr ResetPPositions jmp ProgressDone NextLevelProg jsr NextLevel @@ -814,6 +815,7 @@ NextMap lda #0 ; now add 6 for each number rolled NextMapLoop + clc adc Temp dey bne NextMapLoop @@ -1242,7 +1244,8 @@ DigitGfx: ; the room table holds pf information for each 1/2 scanline as a byte. 45 bytes ; All rooms require PF1 and PF2 tables as well -Room1LayoutPF0: +; Reminder that pf0 only uses 4 bits +Room0LayoutPF0: .byte %11110000 .byte %00010000 .byte %00010000 @@ -1265,7 +1268,10 @@ Room1LayoutPF0: .byte %00010000 .byte %00010000 .byte %11110000 -Room1LayoutPF1: + .byte %11111111 + .byte %11111111 + .byte %11111111 +Room0LayoutPF1: .byte %11111111 .byte %00000000 .byte %00000000 @@ -1288,7 +1294,10 @@ Room1LayoutPF1: .byte %00000000 .byte %00000000 .byte %11111111 -Room1LayoutPF2: + .byte %11111111 + .byte %11111111 + .byte %11111111 +Room0LayoutPF2: .byte %11111111 .byte %10000000 .byte %00000000 @@ -1311,10 +1320,92 @@ Room1LayoutPF2: .byte %00000000 .byte %10000000 .byte %11111111 + .byte %11111111 + .byte %11111111 + .byte %11111111 + +Room1LayoutPF0 + .byte %000001111 + .byte %000000001 + .byte %000000001 + .byte %000000001 + .byte %000111001 + .byte %000001001 + .byte %000001001 + .byte %000000001 + .byte %000000001 + .byte %000000001 + .byte %010001001 + .byte %010001001 + .byte %000000001 + .byte %000000001 + .byte %000000001 + .byte %000001001 + .byte %000001001 + .byte %000111001 + .byte %000000001 + .byte %000000001 + .byte %000000001 + .byte %000000001 + .byte %000000001 + .byte %000001111 +Room1LayoutPF1 + .byte %00000000 + .byte %00000000 + .byte %00000000 + .byte %00000000 + .byte %00111110 + .byte %00000010 + .byte %00000010 + .byte %00000010 + .byte %00000010 + .byte %00000010 + .byte %11111110 + .byte %11111110 + .byte %00000010 + .byte %00000010 + .byte %00000010 + .byte %00000010 + .byte %00000010 + .byte %00111110 + .byte %00000000 + .byte %00000000 + .byte %00000000 + .byte %00000000 + .byte %00000000 + .byte %00000000 +Room1LayoutPF2 + .byte %00000000 + .byte %00000000 + .byte %00111110 + .byte %00100000 + .byte %00100000 + .byte %00100000 + .byte %00100000 + .byte %00100000 + .byte %00100000 + .byte %00100000 + .byte %00100000 + .byte %00100000 + .byte %00100000 + .byte %00100000 + .byte %00100000 + .byte %00100000 + .byte %00100000 + .byte %00100000 + .byte %00100000 + .byte %00111110 + .byte %00000000 + .byte %00000000 + .byte %00000000 + .byte %00000000 ; Table holding all the room start addresses next to each other RoomTable: + .word Room0LayoutPF0 + .word Room0LayoutPF1 + .word Room0LayoutPF2 .word Room1LayoutPF0 .word Room1LayoutPF1 .word Room1LayoutPF2 diff --git a/makefile b/makefile index fbe0a27..ff01d45 100644 --- a/makefile +++ b/makefile @@ -1,5 +1,5 @@ all: - dasm main.asm -f3 -v5 -o./bin/game.bin -l./bin/game.lst -s./bin/game.sym + dasm main.asm -f3 -v5 -o./bin/tb.bin -l./bin/tb.lst -s./bin/tb.sym clean: rm ./bin/*.bin diff --git a/tools/png2bin/readme.md b/tools/png2bin/readme.md index ca654fd..7e92d66 100644 --- a/tools/png2bin/readme.md +++ b/tools/png2bin/readme.md @@ -1,3 +1,3 @@ -This is a simple tool used to convert N by N sized images to byte arrays. +This is a simple tool used to convert N by 8 sized images to byte arrays. I used it to simplify making sprites and maps. -All images must be multiples of 8 in size! +All images must be multiples of 8 in height! diff --git a/tools/png2bin/src/imageconverter.cpp b/tools/png2bin/src/imageconverter.cpp index 3a38168..2b3f12f 100644 --- a/tools/png2bin/src/imageconverter.cpp +++ b/tools/png2bin/src/imageconverter.cpp @@ -1,7 +1,7 @@ #include"include/imageconverter.h" #include"include/colour.h" #include -#include +#include #include #include #include @@ -30,19 +30,10 @@ namespace Image { x * width + y This simulates a 2d array with less of a memory mess */ - this->converted = new unsigned int[image->get_width() * image->get_height()]; - if(!this->converted) { - std::cerr << red << "[FATAL] " << def - << "Unable to allocate enough memory for converted image!" << std::endl; - exit(-1); - } } ImageConverter::~ImageConverter() { // TODO error when freeing - if(this->converted) { - delete[] this->converted; - } if(this->image) { delete this->image; @@ -53,9 +44,10 @@ namespace Image { if(settings->verbose) { std::cout << "Converting pixels" << std::endl; } - - for(int w = 0; w < this->image->get_width(); w++) { - for(int h = 0; h < this->image->get_height(); h++) { + converted.clear(); + for(int h = 0; h < this->image->get_height(); h++) { + converted.emplace_back(std::vector()); + for(int w = 0; w < this->image->get_width(); w++) { png::rgb_pixel pixel = image->get_pixel(w, h); // converted pixel @@ -100,6 +92,8 @@ namespace Image { std::cerr << "Pixel (" << w << "/" << h << ") " << red << "[WARNING] " << def << "Colour " << hexColour << " not found in list. Defaulting to 0 " << std::endl; + + colourFound = 0; } if(settings->verbose) { @@ -110,9 +104,9 @@ namespace Image { << (short)pixel.blue << " " << hexColour << std::endl; } - this->converted[w * image->get_width() + h] = pixelConverted; + converted[h].emplace_back(pixelConverted); if(settings->verbose) { - std::cout << "Set " << this->converted[w * image->get_width() + h] << "(" << + std::cout << "Set " << converted[w][h] << "(" << w * image->get_width() + h << "th element)\n\n"; } } @@ -121,33 +115,26 @@ namespace Image { void ImageConverter::writePixels() { std::ofstream outfile; - outfile.open(settings->outfile); - if(settings->outputBase == "detailed") { - if(settings->verbose) std::cout << "Outputting sprite in detailed mode!\n"; - - // outputting to file - unsigned short stepCounter = image->get_width() / 8; - for(int sc = 0; sc < stepCounter; sc++) { - // each of these loops will write 8 by 8 pixels at most so we loop N times to get all arrays - outfile << "; Sprite of " << settings->inputfile << " Part " << sc << "/" << stepCounter << std::endl; - for(int x = 0; x < image->get_width(); x++) { - outfile << ".byte "; - - for(int y = stepCounter * 8 - 8; y < 8 * stepCounter; y++) { - if(y < image->get_width()) { - outfile << converted[x * image->get_width() + y]; - } else { - outfile << 0; - } - } - outfile << std::endl; + + // outputting to file + outfile << "; Sprite of " << settings->inputfile << std::endl; + for(int x = 0; x < image->get_height(); x++) { + outfile << ".byte \%"; + // pf0 is inverted! + if(settings->outputBase == "p0") { + for(int y = image->get_width(); y >= 0; y--) { + outfile << converted[x][y]; + } + } else { + for(int y = 0; y < image->get_width(); y++) { + outfile << converted[x][y]; } - outfile << std::endl; } - - outfile << std::endl << std::endl; + outfile << std::endl; } + outfile << std::endl; + outfile.close(); } } diff --git a/tools/png2bin/src/include/imageconverter.h b/tools/png2bin/src/include/imageconverter.h index ea4ada9..4d21937 100644 --- a/tools/png2bin/src/include/imageconverter.h +++ b/tools/png2bin/src/include/imageconverter.h @@ -4,13 +4,14 @@ #include #include #include"util.h" +#include namespace Image { class ImageConverter { private: png::image *image; - unsigned int *converted; // converted image for each pixel + std::vector > converted; // converted image for each pixel Settings *settings; public: diff --git a/tools/png2bin/src/util.cpp b/tools/png2bin/src/util.cpp index 0720006..6425609 100644 --- a/tools/png2bin/src/util.cpp +++ b/tools/png2bin/src/util.cpp @@ -22,12 +22,12 @@ void init() { // set default options globalsettings.appmode = "sprite"; - globalsettings.outputBase = "detailed"; + globalsettings.outputBase = "default"; globalsettings.colours = (uint32_t*)malloc(5 * sizeof(uint32_t)); // set default colour pallette - globalsettings.colours[0] = 0x000000; - globalsettings.colours[1] = 0xFFFFFF; + globalsettings.colours[0] = 0xFFFFFF; + globalsettings.colours[1] = 0x000000; globalsettings.coloursLen = 2; @@ -57,7 +57,7 @@ void parseArgs(int argc, char **argv) { "-v\t(optional) Outputs version information\n" << "-f ./example.png\t(required) Set the file that is to be converted\n" << "-o ./output\t(optional) Set the output file and directory\n" << - "-b detailed/compressed\t(optional) Set the base to output the data in (defaults to detailed)\n" << + "-b p0/default\t(optional) Set the base to output the data in (defaults to detailed)\n" << "verbose\t(optional) Verbose mode."; } else if(arg == "-f") { if(extraArgumentsNeeded(1, argc, index)) { @@ -70,7 +70,7 @@ void parseArgs(int argc, char **argv) { } else if(arg == "-o") { if(extraArgumentsNeeded(1, argc, index)) { index++; - globalsettings.outfile = argv[index]; + globalsettings.outfile = argv[index] + '\0'; } else { std::cerr << red << "[FATAL]" << def << " Insufficent arguments: Use -h for syntax!" << std::endl; exit(-1);