More conio fun. Add some ifndefs

master
Astoria 2 years ago
parent 067a4c5e0e
commit 465881c9b2

@ -2,6 +2,7 @@ LD = ../bin/ld65
AS = ../bin/ca65 AS = ../bin/ca65
CC = ../bin/cc65 CC = ../bin/cc65
AL = ../bin/align AL = ../bin/align
CL = ../bin/cl65
CINCLUDE = -I../include CINCLUDE = -I../include
CFLAGS = -t none --cpu $(CPU) CFLAGS = -t none --cpu $(CPU)
@ -24,8 +25,8 @@ all: $(IMAGES)
%.o: %.s %.o: %.s
$(AS) $(CFLAGS) $< $(AS) $(CFLAGS) $<
%.img: %.o %.img: %.o conio.o
$(LD) $(LFLAGS) $< $(LLIBS) -o $@ $(LD) $(LFLAGS) $< conio.o $(LLIBS) -o $@
$(AL) $@ $(AL) $@

@ -1,31 +1,24 @@
#include "conio.h" #include "conio.h"
#include <string.h> #include <string.h>
#include <redbus.h>
#include <console.h>
#define redbus 0x0300 #define redbus 0x0300
int conid = 0x01; int conid = 0x01;
Console* con = (Console*)redbus;
char * strinv(char str[]) { char * strinv(char str[]) {
int i;
for(i = 0; i < strlen(str); i++){ for(i = 0; i < strlen(str); i++){
str[i] = inv(str[i]); str[i] = inv(str[i]);
} }
return str; return str;
} }
void conprint(char str[], int x, int y, int mode){ void conprint(char * str, int x, int y){
con = (Console*)redbus;
rb_map_device(conid); rb_map_device(conid);
str_size = strlen(str); con->line = y;
con->cursor_mode = mode; memcpy(con->display + x, str, strlen(str));
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];
}
} }
void set_conid(int id){ void set_conid(int id){
@ -34,4 +27,29 @@ void set_conid(int id){
int get_conid(){ int get_conid(){
return 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;
} }

@ -1,6 +1,9 @@
int i; #ifndef CONIO_H
int line; #define CONIO_H
int str_size;
Console* con;
char * strinv(char str[]); char * strinv(char str[]);
void conprint(char str[], int x, int y, int mode); 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

@ -21,5 +21,6 @@ void main() {
rb_map_device(IOXID); rb_map_device(IOXID);
expand->out = 0; expand->out = 0;
output = (int*)expand->in; output = (int*)expand->in;
conprint(strinv("Huzzah, inverted text!"), 0, 0, 3); conprint("aeiou", 0, 0);
set_cursor_pos(5,5);
} }

@ -1,3 +1,5 @@
#ifndef RB_CONSOLE
#define RB_CONSOLE
//console.h //console.h
// 0x00 Memory access row. Used to set which line of characters appears in the display memory window. // 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 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) #define scroll(x, y, ox, oy, w, h) blit(3, x, y, ox, oy, w, h)
#endif

Loading…
Cancel
Save