Skip to content

Commit 85c567b

Browse files
authored
Merge pull request #32 from brad-colbert/save_gfx_mode
v1.2.10 Save gfx mode
2 parents 5d5f22e + 062ce92 commit 85c567b

File tree

10 files changed

+165
-117
lines changed

10 files changed

+165
-117
lines changed

YAIL.XEX

-1 Bytes
Binary file not shown.

src/app_key.c

Lines changed: 0 additions & 78 deletions
This file was deleted.

src/app_key.h

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/console.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include "consts.h"
88
#include "settings.h"
99
#include "types.h"
10-
#include "app_key.h"
1110
#include "fujinet-io.h"
1211
#include "utility.h"
1312

@@ -28,7 +27,6 @@ extern void* ORG_SDLIST;
2827
extern void graphics_8_console_dl[];
2928
extern void graphics_9_console_dl[];
3029
extern Settings settings;
31-
extern byte CURRENT_MODE;
3230

3331
// Globals
3432
bool console_state = false;
@@ -110,7 +108,7 @@ void process_command(byte ntokens)
110108
#else
111109
"stream - [arg0...argN] Stream images\n\r";
112110
#endif
113-
byte SAVED_MODE = CURRENT_MODE;
111+
byte SAVED_MODE = settings.gfx_mode;
114112

115113
setGraphicsMode(GRAPHICS_0);
116114
cputs(help); // Show the help text
@@ -152,6 +150,10 @@ void process_command(byte ntokens)
152150
break;
153151
}
154152
}
153+
154+
// Save the graphics mode if not in text mode
155+
if(settings.gfx_mode > GRAPHICS_0)
156+
put_settings(SETTINGS_GFX); // save the graphics mode on the FN
155157
}
156158

157159
if(strncmp(tokens[0], "cls", 3) == 0)
@@ -214,9 +216,8 @@ void process_command(byte ntokens)
214216
{
215217
if(strncmp(tokens[1], "server", 3) == 0)
216218
{
217-
//strncpy(server, tokens[2], 79);
218-
strncpy(settings.url, tokens[2], MAX_APPKEY_LEN);
219-
put_settings(); // save the URL on the FN
219+
strncpy(settings.url, tokens[2], SERVER_URL_SIZE);
220+
put_settings(SETTINGS_URL); // save the URL on the FN
220221
}
221222
}
222223
}

src/graphics.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "console.h"
44
#include "files.h"
55
#include "utility.h"
6+
#include "settings.h"
67
#include "consts.h"
78
#include "types.h"
89

@@ -38,14 +39,14 @@ byte framebuffer[FRAMEBUFFER_SIZE + 32]; // 32 bytes of padding
3839
//
3940
extern char* console_buff;
4041
extern byte console_lines;
42+
extern Settings settings;
4143

4244
// Globals
4345
void* ORG_SDLIST = 0;
4446
void* VDSLIST_STATE = 0;
4547
byte ORG_GPRIOR = 0x0;
4648
byte NMI_STATE = 0x0;
4749
byte ORG_COLOR1, ORG_COLOR2;
48-
byte CURRENT_MODE = 0;
4950
DLDef dlDef;
5051
ImageData image = { {0, 0, 0, 0, 0, 0}, framebuffer };
5152

@@ -113,7 +114,7 @@ void restoreGraphicsState(void)
113114

114115
void setGraphicsMode(const byte mode)
115116
{
116-
if(mode == CURRENT_MODE)
117+
if(mode == settings.gfx_mode)
117118
return;
118119

119120
makeDisplayList(mode);
@@ -165,7 +166,7 @@ void setGraphicsMode(const byte mode)
165166
break;
166167
}
167168

168-
CURRENT_MODE = mode;
169+
settings.gfx_mode = mode;
169170
}
170171

171172
void makeDisplayList(byte mode)
@@ -194,15 +195,15 @@ void makeDisplayList(byte mode)
194195

195196
void show_console()
196197
{
197-
switch(CURRENT_MODE)
198+
switch(settings.gfx_mode)
198199
{
199200
case GRAPHICS_0: // {0, DL_CHR40x8x1, 1, 0, CONSOLE_MEM}
200201
break;
201202
case GRAPHICS_8: // {8, DL_MAP320x1x1, 211, 0, 0}
202203
{
203-
CURRENT_MODE |= GRAPHICS_CONSOLE_EN;
204+
settings.gfx_mode |= GRAPHICS_CONSOLE_EN;
204205

205-
makeDisplayList(CURRENT_MODE);
206+
makeDisplayList(settings.gfx_mode);
206207

207208
OS.sdlst = dlDef.address;
208209
ANTIC.nmien = 0x40;
@@ -213,9 +214,9 @@ void show_console()
213214
case GRAPHICS_10:
214215
case GRAPHICS_11:
215216
{
216-
CURRENT_MODE |= GRAPHICS_CONSOLE_EN;
217+
settings.gfx_mode |= GRAPHICS_CONSOLE_EN;
217218

218-
makeDisplayList(CURRENT_MODE);
219+
makeDisplayList(settings.gfx_mode);
219220

220221
OS.sdlst = dlDef.address;
221222
OS.vdslst = disable_9_dli;
@@ -227,7 +228,7 @@ void show_console()
227228

228229
void hide_console()
229230
{
230-
switch(CURRENT_MODE) // ^ GRAPHICS_CONSOLE_EN)
231+
switch(settings.gfx_mode) // ^ GRAPHICS_CONSOLE_EN)
231232
{
232233
case GRAPHICS_0: // {0, DL_CHR40x8x1, 1, 0, CONSOLE_MEM}
233234
break;
@@ -236,9 +237,9 @@ void hide_console()
236237
case GRAPHICS_10_CONSOLE:
237238
case GRAPHICS_11_CONSOLE:
238239
{
239-
CURRENT_MODE &= (byte)~GRAPHICS_CONSOLE_EN;
240+
settings.gfx_mode &= (byte)~GRAPHICS_CONSOLE_EN;
240241

241-
makeDisplayList(CURRENT_MODE);
242+
makeDisplayList(settings.gfx_mode);
242243
//POKEW(SDLSTL, gfxState.dl.address);
243244

244245
OS.sdlst = dlDef.address;

src/imgload.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include "files.h"
44
#include "utility.h"
55
#include "netimage.h"
6-
#include "app_key.h"
76
#include "settings.h"
87
#include "version.h"
98
#include "utility.h"
@@ -21,7 +20,7 @@ char version[] = "YAIL (Yet Another Image Loader) v" TOSTR(MAJOR_VERSION) "." TO
2120

2221
char buff[256]; // A block of memory to be used by all.
2322
bool done = false;
24-
Settings settings;
23+
extern Settings settings;
2524

2625
void help()
2726
{
@@ -62,9 +61,6 @@ int main(int argc, char* argv[])
6261
// Convert the version string to internal code format
6362
atascii_to_internal(version, 40);
6463

65-
// Initialize the settings
66-
get_settings();
67-
6864
//
6965
if(argc > 1)
7066
{
@@ -78,7 +74,9 @@ int main(int argc, char* argv[])
7874

7975
// Initialize the frame buffer
8076
saveCurrentGraphicsState();
81-
setGraphicsMode(GRAPHICS_8);
77+
78+
// Initialize the settings. Set defaults if no saved settings are found.
79+
get_settings();
8280
clearFrameBuffer();
8381

8482
// Show console on startup

src/netimage.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
//
1717
extern byte buff[];
1818
extern ImageData image;
19-
extern byte CURRENT_MODE;
2019
extern Settings settings;
2120

2221
void stream_image(char* args[])
@@ -60,7 +59,7 @@ void stream_image(char* args[])
6059

6160
// Send which graphics mode we are in
6261
memset(buff, 0, 256);
63-
sprintf(buff, "gfx %d ", CURRENT_MODE &= ~GRAPHICS_CONSOLE_EN);
62+
sprintf(buff, "gfx %d ", settings.gfx_mode &= ~GRAPHICS_CONSOLE_EN);
6463
if(FN_ERR_OK != network_write(settings.url, buff, 6))
6564
{
6665
show_console();

0 commit comments

Comments
 (0)