mirror of
https://github.com/deater/dos33fsprogs.git
synced 2024-11-01 01:06:33 +00:00
c05084c289
probably broke something, but this also was a pain as was often accidentally using the vars, especially X and Y
107 lines
1.4 KiB
C
107 lines
1.4 KiB
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <unistd.h>
|
|
#include <string.h>
|
|
|
|
#include "tfv_utils.h"
|
|
#include "gr-sim.h"
|
|
#include "tfv_zp.h"
|
|
|
|
int repeat_until_keypressed(void) {
|
|
|
|
int ch;
|
|
|
|
while(1) {
|
|
ch=grsim_input();
|
|
if (ch!=0) break;
|
|
|
|
usleep(10000);
|
|
}
|
|
|
|
return ch;
|
|
}
|
|
|
|
int select_menu(int x, int y, int num, char **items) {
|
|
|
|
int result=0;
|
|
int ch,i;
|
|
|
|
while(1) {
|
|
for(i=0;i<num;i++) {
|
|
htab(x);
|
|
vtab(y+i);
|
|
move_cursor();
|
|
|
|
if (i==result) {
|
|
print_inverse("--> ");
|
|
}
|
|
else {
|
|
print(" ");
|
|
}
|
|
|
|
print(items[i]);
|
|
}
|
|
page_flip();
|
|
|
|
ch=repeat_until_keypressed();
|
|
if (ch=='\r') break;
|
|
if (ch==' ') break;
|
|
if (ch==APPLE_RIGHT) result++;
|
|
if (ch==APPLE_DOWN) result++;
|
|
if (ch==APPLE_LEFT) result--;
|
|
if (ch==APPLE_UP) result--;
|
|
if (result>=num) result=num-1;
|
|
if (result<0) result=0;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
void apple_memset(unsigned char *ptr, int value, int length) {
|
|
|
|
A=value;
|
|
X=length;
|
|
Y=0;
|
|
|
|
while(X>0) {
|
|
ptr[Y]=A;
|
|
Y++;
|
|
X--;
|
|
}
|
|
}
|
|
|
|
void print_u8(unsigned char value) {
|
|
|
|
char temp[4];
|
|
|
|
sprintf(temp,"%d",value);
|
|
|
|
basic_print(temp);
|
|
|
|
}
|
|
|
|
void print_byte(unsigned char value) {
|
|
char temp[4];
|
|
sprintf(temp,"%3d",value);
|
|
temp[3]=0;
|
|
print(temp);
|
|
}
|
|
|
|
void page_flip(void) {
|
|
|
|
if (ram[DISP_PAGE]==0) {
|
|
soft_switch(HISCR);
|
|
ram[DISP_PAGE]=1;
|
|
ram[DRAW_PAGE]=0x0;
|
|
}
|
|
else {
|
|
soft_switch(LOWSCR);
|
|
ram[DISP_PAGE]=0;
|
|
ram[DRAW_PAGE]=0x4;
|
|
}
|
|
|
|
grsim_update();
|
|
|
|
}
|
|
|