Skip to content

Commit

Permalink
v1.0.0; code cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Filip Lewiński <[email protected]>
  • Loading branch information
filipleple committed Jul 24, 2024
1 parent cc6c1b4 commit cbd9117
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 59 deletions.
28 changes: 20 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
pacman
======
# Pacman-libpayload

ASCII Pacman game, written with curses
ASCII Pacman game, written with curses, ported to libpayload to be used
with coreboot.

Use the keys:
## Building

x - left
c - right
k - up
m - down
* Build libpayload
* Start from `coreboot/payloads/pacman` or edit the `lpgcc` path in Makefile
* Run `make`
* Build coreboot with `An ELF executable payload`, pointing to the built
`pacman` file. So far, it's only been tested in qemu.

## Playing

Run `qemu-kvm -bios coreboot.rom -M q35`. Use the keys:

```
x - left
c - right
k - up
m - down
```
to move.
6 changes: 0 additions & 6 deletions porting-journal.md

This file was deleted.

3 changes: 0 additions & 3 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ gameloop.o: pacman.h gameloop.h player.h ghosts.h pills.h board.h render.h
render.o: pacman.h render.h board.h
pills.o: pacman.h pills.h board.h

install:
cat *.c *.h >pactext

clean:
-rm -f *.o pacman pactext

Expand Down
43 changes: 2 additions & 41 deletions src/pacman.c
Original file line number Diff line number Diff line change
@@ -1,45 +1,16 @@
/*
** Pacman - In curses
** Pacman - In curses, for libpayload
*/
#include <ctype.h>
#include "pacman.h"
#include "render.h"
#include "gameloop.h"
#include "libpayload.h"

// void GetMarqueeText(GAME_STATE *ptr) {
// FILE *fp = fopen("pactext", "r");
// int i;
// char *pc;

// ptr->pMarquee = 0;
// if (fp) {
// fseek(fp, 0, SEEK_END);
// ptr->iMarqueeSize = ftell(fp);
// if ((ptr->pMarquee = malloc(ptr->iMarqueeSize))){
// fseek(fp,0,SEEK_SET);
// fread(ptr->pMarquee, 1, ptr->iMarqueeSize, fp);
// pc = ptr->pMarquee;
// for(i=0;i<ptr->iMarqueeSize;i++,pc++)
// if (isalnum(*pc) || ispunct(*pc))
// ;/*empty*/
// else
// *pc = ' ';
// }
// fclose(fp);
// }
// }







void GetMarqueeText(GAME_STATE *ptr)
{
// Hardcoded marquee text (replace this with the actual text if known)
const char *marqueeText = "Pac-Man: Insert Coin to Start! Use Arrow Keys to Move. Eat All Dots to Win!";
const char *marqueeText = "Pac-Man: Insert Coin to Start! Use X - left; C - right; K - up; M - down to Move. Eat All Dots to Win! ";

ptr->iMarqueeSize = strlen(marqueeText);
ptr->pMarquee = (char *)malloc(ptr->iMarqueeSize + 1); // Allocate memory for the text plus null terminator
Expand All @@ -59,16 +30,6 @@ void GetMarqueeText(GAME_STATE *ptr)
}
}











int main(int argc, char **argv) {
GAME_STATE game;
void *pRender;
Expand Down
7 changes: 6 additions & 1 deletion src/render.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#define PC_EDIBLE_GHOST 6
#define PC_GHOST 20

// temporary stub to resolve linker problems
void fwrite(){

}
Expand Down Expand Up @@ -229,7 +230,8 @@ char *szAnim = "|Vv_.+*X*+. ";
void Pac_RenderGameInfo(void *pCtx)
{
char *s1 = "ASCII Pacman - Steven Goodwin 2002";
char *s2 = "Released under the GPL";
char *s2 = "Ported to libpayload by F.L, 2024";
char *s3 = "Released under the GPL";

clear();
attron(COLOR_PAIR(PC_PILL));
Expand All @@ -238,6 +240,9 @@ char *s2 = "Released under the GPL";
attron(COLOR_PAIR(PC_PACMAN));
mvprintw(3,CenteredX(s2), s2);
attroff(COLOR_PAIR(PC_PACMAN));
attron(COLOR_PAIR(PC_PACMAN));
mvprintw(4,CenteredX(s3), s3);
attroff(COLOR_PAIR(PC_PACMAN));
}

void Pac_RenderRHS(void *pCtx, GAME_STATE *ptr)
Expand Down

0 comments on commit cbd9117

Please sign in to comment.