gamejam

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 22bb984aa1e1df8744fca23d329e02b2d5b3ad41
parent 3d4706da7ea4252efb86d6f86883031647385b4d
Author: thing1 <thing1@seacrossedlovers.xyz>
Date:   Sun, 16 Nov 2025 17:46:29 +0000

final commit

Diffstat:
M.gitignore | 1+
MMakefile | 6++++--
Mgame.S | 165++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------
Mmapgen.c | 89++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----------
Amusic.wav | 0
App.c | 17+++++++++++++++++
Mrun | 124+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
7 files changed, 371 insertions(+), 31 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -2,3 +2,4 @@ game map.S mapgen +pp diff --git a/Makefile b/Makefile @@ -4,7 +4,7 @@ LDFLAGS = -static ASFLAGS = -g -L CFLAGS = -ggdb -all: game mapgen +all: mapgen pp game: game.o map.o ${LD} -o game $(LDFLAGS) game.o map.o @@ -14,5 +14,7 @@ map.o: map.S ${AS} -o map.o map.S mapgen: mapgen.c cc -o mapgen ${CFLAGS} mapgen.c +pp: pp.c + cc -o pp ${CFLAGS} pp.c clean: - rm -rf *.o game mapgen map.S + rm -rf *.o game mapgen pp map.S diff --git a/game.S b/game.S @@ -142,7 +142,6 @@ drawtextbuf: mov $2, %rdx syscall - restore ret @@ -155,14 +154,99 @@ drawframe: mov $1000, %rcx mul %rcx add %rax, %r11 + + /* switch on the char to be replaced */ + cmpb $'#', (%r11) + jne .switch22 +.switch21: + mov $outofbounds, %rdi + mov $textbuf, %rsi + call strcpy + jmp .eswitch2 +.switch22: + cmpb $'E', (%r11) + jne .switch23 + mov $person1, %rdi + mov $textbuf, %rsi + call strcpy + jmp .eswitch2 +.switch23: + cmpb $'A', (%r11) + jne .switch24 + mov $person2, %rdi + mov $textbuf, %rsi + call strcpy + jmp .eswitch2 +.switch24: + cmpb $'W', (%r11) + jne .switch25 + mov $person3, %rdi + mov $textbuf, %rsi + call strcpy + jmp .eswitch2 +.switch25: + cmpb $'K', (%r11) + jne .switch26 + mov $person4, %rdi + mov $textbuf, %rsi + call strcpy + jmp .eswitch2 +.switch26: + cmpb $'L', (%r11) + jne .switch27 + mov $person5, %rdi + mov $textbuf, %rsi + call strcpy + jmp .eswitch2 +.switch27: + cmpb $'P', (%r11) + jne .switch28 + mov $person6, %rdi + mov $textbuf, %rsi + call strcpy + jmp .eswitch2 +.switch28: + cmpb $'T', (%r11) + jne .switch29 + mov $person7, %rdi + mov $textbuf, %rsi + call strcpy + mov $gamestate, %rdi + orl $1, (%rdi) + jmp .eswitch2 +.switch29: + cmpb $'C', (%r11) + jne .switch210 + mov $person8, %rdi + mov $textbuf, %rsi + call strcpy + mov $gamestate, %rdi + orl $2, (%rdi) + jmp .eswitch2 +.switch210: + cmpb $'H', (%r11) + jne .switch211 + mov $person9, %rdi + mov $textbuf, %rsi + call strcpy + mov $gamestate, %rdi + orl $4, (%rdi) + jmp .eswitch2 + +.switch211: + cmpb $'D', (%r11) + jne .eswitch2 + mov $60, %rax + mov $0, %rdi + syscall +.eswitch2: + movb $'@', (%r11) - nop mov $map, %rsi call printscreen movb $' ', (%r11) - nop call drawtextbuf @@ -226,29 +310,65 @@ moveplayer: zero: save .loop4: - cmpl %eax, %esi - jle .eloop4 - movb $0, (%rdi,%rax) - incq %rax - jmp .loop4 + mov $0, %rax + cmp %rsi, %rax + je .eloop4 + dec %rsi + movb $0, (%rdi) + inc %rdi + jmp .loop4 .eloop4: restore ret +strcpy: + save + + push %rdi + push %rsi + + mov $textbuf, %rdi + mov $1024, %rsi + call zero + + pop %rsi + pop %rdi + + mov $0, %rbx +.loop5: + xor %rax, %rax + movb (%rdi), %ah + cmp %rax, %rbx + je .eloop5 + + movb %ah, (%rsi) + inc %rdi + inc %rsi + + jmp .loop5 +.eloop5: + restore + ret + _start: - mov $0x48, %rax + mov $0x48, %rax /* set stdin to nonblock */ mov $0, %rdi mov $4, %rsi mov $2048, %rdx syscall - mov $500, %r8 /* set player x and y */ - mov $500, %r9 - mov $0, %r10 /* set game state to 0 */ + mov $505, %r8 /* set player x and y */ + mov $505, %r9 .loop2: call drawframe call moveplayer + + save + mov $7, %rax + movl (gamestate), %ecx + cmp %rax, %rcx + je .docsgrave jmp .loop2 @@ -257,9 +377,26 @@ _start: mov $0, %rdi syscall +.docsgrave: + mov $500500, %r11 + add $map, %r11 + movb $'D', (%r11) + jmp .loop2 .data -textbuf: .ascii "hello world\0" /*.fill 256, 1, 0*/ -speach: +gamestate: .int 0 +textbuf: .fill 1024, 1, 0 +outofbounds: .ascii "System:\n\rStop walking through\n\rwalls!\0" +person1: .ascii "It's no use. We\n\rlost the cure\n\rwhen Doc passed.\0" +person2: .ascii "*sigh* What do you\n\rwant? I don't know\n\ranything. Go find\n\rsomeone else.\0" +person3: .ascii "I don't know how\n\rwe're going to\n\rmanage without\n\rhim. Maybe if\n\rwe could find\n\rthe formula\0" +person4: .ascii "I think we might\n\rhave buried the\n\rcure? No, that's\n\rnot right...\0" +person5: .ascii "I think we\n\rengraved the\n\rformula for the\n\rcure on Doc's\n\rheadstone. It’s no\n\ruse though. The\n\rstone has long since \n\rfallen and is\n\rimpossible to find\n\rwithout help but\n\rnobody remembers\n\rexactly where it\n\ris.\0" +person6: .ascii "I'm not in the\n\rmood to talk to\n\rstrangers. Go away.\0" +person7: .ascii "We laid Doc to\n\rrest just South\n\rof here. I can't\n\rbelieve we're losing\n\ranother one… \0" +person8: .ascii "I’m pretty sure\n\rhe was buried\n\rto the East. I’m\n\rprobably wrong\n\rthough. It's no\n\ruse.\0" +person9: .ascii "Doc's grave? It's\n\rNorth of here… No\n\rwait West…. No,\n\rboth? I feel like\n\rI’m going crazy.\0" +// person10: .ascii "*cough* Doc? Is that\n\ryou? No, of course\n\rnot.I fear I’m\n\ronly getting worse\n\rfrom the infection.\n\rDoc, we need your\n\rhelp from beyond\n\rthe grave! Please… \n\r*The grave is marked \n\ron the map*\0" + nl: .byte '\n', '\r' hash: .byte '#' clear: .ascii "\033c" diff --git a/mapgen.c b/mapgen.c @@ -4,8 +4,11 @@ #include <time.h> #define POS(x) ((x < 0) ? 0 : x) +#define RANDINT(lower, upper) (lower + (rand() % (upper - lower))) char *map; +char *npcs = "EAWKLP"; +char *special = "TCH"; void mk_square(int x, int y, int w) { @@ -14,45 +17,107 @@ mk_square(int x, int y, int w) { for (int i = y; (i - y) < w && i < 1000; i++) { for (int j = x; (j - x) < w && j < 1000; j++) { - map[j + (i * 1000)] = ' '; + if (map[j + (i * 1000)] == '#') { + if (rand() % 17 == 0) + map[j + (i * 1000)] = '.'; + else + map[j + (i * 1000)] = ' '; + } } } } -void -print_map() { - printf(".globl map\n.data\nmap:\n.byte "); - for (int i = 0; i < 1000; i++) { - for (int j = 0; j < 1000; j++) - printf("'%c'%s", map[j + (i * 1000)], (j == 999) ? "" : ", "); - printf("\n%s", (i == 999) ? "" : ".byte "); +void +mk_line(int x1, int y1, int x2, int y2, int w) { + float m = (float)((float)(y2 - y1) / (float)(x2 - x1)); + float c = y1 - (m * x1); + + int dir = (x1 < x2) ? 1 : -1; + + for (int i = x1; i != x2; i += dir) { + mk_square(i, (m * i + c), 10); } } +void +place_npc(int x, int y) { + if (!*npcs) return; + map[x + y * 1000] = *npcs; + npcs++; +} + void mk_map(int x, int y, int w) { int x2, y2; - if (w < 10) return; + if (w < 30) return; mk_square(x, y, w); - for (int i = 0; i < 16; i++) { - srand(time(NULL)); + srand(time(NULL)); + for (int i = 0; i < 4; i++) { x2 = (rand() % (w * 3)); y2 = (rand() % (w * 3)); x2 = (rand() % 2) ? x2 : -x2; y2 = (rand() % 2) ? y2 : -y2; + mk_line(x, y, x + x2, y + y2, 1); mk_map(x + x2, y + y2, w / 2); + place_npc(x + x2, y + y2); + } +} + +void +place_special1() { + int x, y; + do { + x = RANDINT(300, 700); + y = RANDINT(500, 800); + } while (map[x + y * 1000] != ' '); + + map[x + y * 1000] = 'T'; +} + +void +place_special2() { + int x, y; + do { + x = RANDINT(200, 500); + y = RANDINT(300, 700); + } while (map[x + y * 1000] != ' '); + + map[x + y * 1000] = 'C'; +} + +void +place_special3() { + int x, y; + do { + x = RANDINT(500, 800); + y = RANDINT(500, 800); + } while (map[x + y * 1000] != ' '); + + map[x + y * 1000] = 'H'; +} + +void +print_map() { + printf(".globl map\n.data\nmap:\n.byte "); + for (int i = 0; i < 1000; i++) { + for (int j = 0; j < 1000; j++) + printf("'%c'%s", map[j + (i * 1000)], (j == 999) ? "" : ", "); + printf("\n%s", (i == 999) ? "" : ".byte "); } } + int main() { map = malloc(1000 * 1000); memset(map, '#', 1000 * 1000); mk_map(500, 500, 100); - /* need to make this connect all boxes made */ + place_special1(); + place_special2(); + place_special3(); print_map(); } diff --git a/music.wav b/music.wav Binary files differ. diff --git a/pp.c b/pp.c @@ -0,0 +1,17 @@ +#include <stdio.h> +#include <unistd.h> +#include <stdlib.h> +#include <time.h> + +int +main() { + char c; + long t; + srand(time(NULL)); + while ((c = getchar()) != EOF) { + putchar(c); + fflush(stdout); + while ((t = (rand() % 150000)) > 250000); + usleep(t); + } +} diff --git a/run b/run @@ -1,9 +1,127 @@ #!/bin/sh +clear +aplay music.wav &> /dev/null & + +echo """ + _/ + _/_/_/ _/ + _/ _/ _/_/ _/_/_/ _/_/_/ + _/ _/ _/ _/ _/ _/_/ + _/ _/ _/ _/ _/ _/_/ +_/_/_/ _/_/ _/_/_/ _/_/_/ + + + + _/_/_/ _/ _/ + _/ _/_/_/ _/_/ _/_/_/ _/_/_/_/ + _/ _/_/ _/ _/ _/ _/ _/_/ _/ +_/ _/ _/ _/ _/ _/ _/_/ _/ + _/_/_/ _/ _/ _/_/ _/_/_/ _/_/ + +Developed by Lucas Written by Laura +Music ripped from Hollow Knight +""" + +sleep 3 + +clear + +echo """ +Hey...you...are +you here to help? +""" | fmt | ./pp + +echo """ +What's going on, +are you the only one +here? +""" | fmt | ./pp + +echo """ +No...I'm just the +only one who cares +to stay anymore. +Don't you remember +what happened? The +infection...so many +lives lost...there +are only 10 of us +left but one is +still very sick. +Sadly, nobody can +remember the cure +and so we are +preparing for a +funeral in +the village. +""" | fmt | ./pp + +echo """ +I can look for the +cure. Where should I +start? +""" | fmt | ./pp + +echo """ +Try talking to the +others. They may +have some ideas. +""" | fmt | ./pp + +sleep 1 + old=$(stty -g) ./mapgen > map.S -make +make game stty raw -echo -./game -stty "$old" + + +(sleep 10m && kill $(pidof game)) & +./game && if [[ $? -eq 0 ]]; then + stty "$old" + clear + + echo """ + You found the + formula for the cure + on time! You were able + to save the I'll from + dying. Because + you found the cure, + you were also able + to cure yourself of + a budding infection + that you had not + noticed during your + adventure. You were + handsomely rewarded + for your efforts. + THE END + """ | fmt | ./pp +else + stty "$old" + clear + + echo """ + You ran out of time! + Sadly, the person + passed from the + infection. During + your adventure, you + also got infected. + Nobody knew the + cure to save you. + Sadly, the village + had two funerals + that night. + THE END + """ | fmt | ./pp + + +fi + + +pkill -P $$ +