From 465881c9b2993292f894183c2a3b597c4d198210 Mon Sep 17 00:00:00 2001 From: Astoria Date: Sat, 14 Jan 2023 21:32:33 -0600 Subject: [PATCH] More conio fun. Add some ifndefs --- IOX/Makefile | 5 +++-- IOX/conio.c | 46 ++++++++++++++++++++++++++++++++-------------- IOX/conio.h | 13 ++++++++----- IOX/test_iox.c | 3 ++- include/console.h | 4 +++- 5 files changed, 48 insertions(+), 23 deletions(-) diff --git a/IOX/Makefile b/IOX/Makefile index b3bcba9..e439a39 100644 --- a/IOX/Makefile +++ b/IOX/Makefile @@ -2,6 +2,7 @@ LD = ../bin/ld65 AS = ../bin/ca65 CC = ../bin/cc65 AL = ../bin/align +CL = ../bin/cl65 CINCLUDE = -I../include CFLAGS = -t none --cpu $(CPU) @@ -24,8 +25,8 @@ all: $(IMAGES) %.o: %.s $(AS) $(CFLAGS) $< -%.img: %.o - $(LD) $(LFLAGS) $< $(LLIBS) -o $@ +%.img: %.o conio.o + $(LD) $(LFLAGS) $< conio.o $(LLIBS) -o $@ $(AL) $@ diff --git a/IOX/conio.c b/IOX/conio.c index 42fcf14..3c4467a 100644 --- a/IOX/conio.c +++ b/IOX/conio.c @@ -1,31 +1,24 @@ #include "conio.h" #include +#include +#include #define redbus 0x0300 - int conid = 0x01; +Console* con = (Console*)redbus; char * strinv(char str[]) { + int i; for(i = 0; i < strlen(str); i++){ str[i] = inv(str[i]); } return str; } -void conprint(char str[], int x, int y, int mode){ - con = (Console*)redbus; +void conprint(char * str, int x, int y){ rb_map_device(conid); - str_size = strlen(str); - con->cursor_mode = mode; - line = y; - con->line = line; - for (i = 0; i < str_size; i++){ - if (((y % 50) + (x + i) / 80) != line) { - line = (y % 50) + (x + i) / 80; - con->line = line; - } - con->display[(int)(x + i) % 80] = str[i]; - } + con->line = y; + memcpy(con->display + x, str, strlen(str)); } void set_conid(int id){ @@ -34,4 +27,29 @@ void set_conid(int id){ int get_conid(){ return conid; +} + +struct cursor_pos { + int x; + int y; +}; + +void set_cursor_pos(int x, int y) { + con->cursor_x = x; + con->cursor_y = y; +} + +struct cursor_pos get_cursor_pos() { + struct cursor_pos cursor; + cursor.x = con->cursor_x; + cursor.y = con->cursor_y; + return cursor; +} + +void set_cursor_mode(int mode) { + con->cursor_mode = mode; +} + +int get_cursor_mode() { + return con->cursor_mode; } \ No newline at end of file diff --git a/IOX/conio.h b/IOX/conio.h index 19d02c1..6f03ad2 100644 --- a/IOX/conio.h +++ b/IOX/conio.h @@ -1,6 +1,9 @@ -int i; -int line; -int str_size; -Console* con; +#ifndef CONIO_H +#define CONIO_H char * strinv(char str[]); -void conprint(char str[], int x, int y, int mode); \ No newline at end of file +void set_conid(int id); +int get_conid(); +void set_cursor_pos(int x, int y); +void set_cursor_mode(int mode); +int get_cursor_mode(); +#endif \ No newline at end of file diff --git a/IOX/test_iox.c b/IOX/test_iox.c index 2027ea1..a1ea206 100644 --- a/IOX/test_iox.c +++ b/IOX/test_iox.c @@ -21,5 +21,6 @@ void main() { rb_map_device(IOXID); expand->out = 0; output = (int*)expand->in; - conprint(strinv("Huzzah, inverted text!"), 0, 0, 3); + conprint("aeiou", 0, 0); + set_cursor_pos(5,5); } \ No newline at end of file diff --git a/include/console.h b/include/console.h index 8eb83b7..b385290 100644 --- a/include/console.h +++ b/include/console.h @@ -1,3 +1,5 @@ +#ifndef RB_CONSOLE +#define RB_CONSOLE //console.h // 0x00 Memory access row. Used to set which line of characters appears in the display memory window. @@ -52,4 +54,4 @@ typedef struct Console { #define invert(x, y, w, h) blit(2, 0, 0, x, y, w, h) #define scroll(x, y, ox, oy, w, h) blit(3, x, y, ox, oy, w, h) - +#endif