Browse Source

Rename api.h

Johannes Zellner 8 months ago
parent
commit
8d22d69c75
5 changed files with 6 additions and 46 deletions
  1. 3 3
      Makefile
  2. 1 1
      prog.c
  3. 0 40
      prog_api.h
  4. 1 1
      run.c
  5. 1 1
      space.c

+ 3 - 3
Makefile

@@ -53,7 +53,7 @@ ls.o: ls.c fat.h io.h
 cat.o: cat.c fat.h io.h
 	$(CC) $(CFLAGS) -o $@ $<
 
-run.o: run.c fat.h io.h fbtext.h prog_api.h timer.h vga.h
+run.o: run.c fat.h io.h fbtext.h run_api.h timer.h vga.h
 	$(CC) $(CFLAGS) -o $@ $<
 
 rtc.o: rtc.c rtc.h
@@ -108,7 +108,7 @@ final.bin: boot.bin kernel.bin
 	cat boot.bin.patched kernel.bin > $@; \
 	rm -f boot.bin.patched
 
-prog.o: prog.c prog_api.h
+prog.o: prog.c run_api.h
 	$(CC) $(CFLAGS) -o $@ $<
 
 prog.elf: prog.o
@@ -117,7 +117,7 @@ prog.elf: prog.o
 prog.bin: prog.elf
 	$(OBJCOPY) -O binary $< $@
 
-space.o: space.c prog_api.h
+space.o: space.c run_api.h
 	$(CC) $(CFLAGS) -o $@ $<
 
 space.elf: space.o

+ 1 - 1
prog.c

@@ -1,6 +1,6 @@
 /* Example user program: draws "omg!" centered, runs until ESC. Uses kernel API at PROGRAM_API_ADDR. */
 
-#include "prog_api.h"
+#include "run_api.h"
 
 /* Character cell size used by fbtext (8px wide, 10px row height). */
 #define CHAR_WIDTH  8

+ 0 - 40
prog_api.h

@@ -1,40 +0,0 @@
-/* API passed to loaded program at PROGRAM_API_ADDR. Used by run.c and prog.c. */
-
-#ifndef PROG_API_H
-#define PROG_API_H
-
-#define PROGRAM_API_ADDR 0x20F00
-#define IO_KEY_ESC       0x1B
-#define IO_KEY_SPACE     0x20
-#define IO_KEY_LEFT      0x100
-#define IO_KEY_RIGHT     0x101
-
-/* Function pointer types for the program API. */
-typedef void (*prog_draw_string_xy_t)(unsigned int x0, unsigned int y0,
-	const char *str, unsigned int r_fg, unsigned int g_fg, unsigned int b_fg,
-	int transparent_bg);
-typedef unsigned int (*prog_get_cols_t)(void);
-typedef unsigned int (*prog_get_rows_t)(void);
-typedef int (*prog_poll_key_t)(void);
-typedef int (*prog_poll_key_with_hw_t)(void);
-typedef unsigned int (*prog_get_fb_width_t)(void);
-typedef unsigned int (*prog_get_fb_height_t)(void);
-typedef void (*prog_clear_rgb_t)(unsigned int r, unsigned int g, unsigned int b);
-typedef void (*prog_put_pixel_rgb_t)(unsigned int x, unsigned int y,
-	unsigned int r, unsigned int g, unsigned int b);
-typedef unsigned int (*prog_get_ticks_ms_t)(void);
-
-struct prog_api {
-	prog_draw_string_xy_t draw_string_xy;
-	prog_get_cols_t       get_cols;
-	prog_get_rows_t       get_rows;
-	prog_poll_key_t       poll_key;
-	prog_poll_key_with_hw_t poll_key_with_hw;
-	prog_get_fb_width_t   get_fb_width;
-	prog_get_fb_height_t  get_fb_height;
-	prog_clear_rgb_t      clear_rgb;
-	prog_put_pixel_rgb_t  put_pixel_rgb;
-	prog_get_ticks_ms_t   get_ticks_ms;
-};
-
-#endif

+ 1 - 1
run.c

@@ -3,7 +3,7 @@
 #include "fat.h"
 #include "fbtext.h"
 #include "io.h"
-#include "prog_api.h"
+#include "run_api.h"
 #include "timer.h"
 #include "vga.h"
 

+ 1 - 1
space.c

@@ -1,6 +1,6 @@
 /* Simple Space Invaders: pixel graphics, keyboard input. Uses kernel API at PROGRAM_API_ADDR. */
 
-#include "prog_api.h"
+#include "run_api.h"
 
 #define INV_ROWS      5
 #define INV_COLS      10