From de1b7b3e72fa4491aed606f7cad4b3d78c7f7242 Mon Sep 17 00:00:00 2001 From: ttwilb Date: Thu, 13 Mar 2014 00:26:39 +0900 Subject: [PATCH] screen.c --- screen.c | 208 +++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 104 insertions(+), 104 deletions(-) diff --git a/screen.c b/screen.c index 878a1c1..447a2c3 100644 --- a/screen.c +++ b/screen.c @@ -1,105 +1,105 @@ -#include "osecpu.h" - -void putOsaskChar(int c, HOSECPU_RuntimeEnvironment *r) -{ - if (0x10 <= c && c <= 0x1f){ - c = "0123456789ABCDEF"[c & 0x0f]; - } - putchar(c); - r->lastConsoleChar = c; - return; -} - -void checkString(HOSECPU_RuntimeEnvironment *r, int rxx, int pxx) -{ - char c = 0; - if (r->preg[pxx].typ != 0x03){ - c = 1; - } - if (r->preg[pxx].p < r->preg[pxx].p0){ - c = 1; - } - if (r->ireg[rxx] < 0){ - c = 1; - } - if (r->preg[pxx].p + r->ireg[rxx] > r->preg[pxx].p1){ - c = 1; - } - if (c != 0){ - (*(r->errHndl))(r); - } - return; -} - -int loadColor(HOSECPU_RuntimeEnvironment *r, int rxx) -{ - int c, m, rr, gg, bb; - c = r->ireg[rxx]; - m = r->ireg[0x31] & 0x0c; - if (m == 0x04) { - if (c < -1 || c > 7){ - (*(r->errHndl))(r); - } - c = iColor1[c & 0x07]; - } - if (m == 0x08) { - // 00, 24, 48, 6d, 91, b6, da, ff - if (c < 0 || c >= (1 << 9)){ - (*(r->errHndl))(r); - } - rr = (c >> 6) & 0x07; - gg = (c >> 3) & 0x07; - bb = c & 0x07; - rr = (rr * 255) / 7; - gg = (gg * 255) / 7; - bb = (bb * 255) / 7; - c = rr << 16 | gg << 8 | bb; - } - if (m == 0x0c) { - // 00, 08, 10, 18, 20, 29, 31, 39, - // 41, 4a, 52, 5a, 62, 6a, 73, 7b, - // 83, 8b, 94, 9c, a4, ac, b4, bd, - // c5, cd, d5, de, e6, ee, f6, ff - if (c < 0 || c >= (1 << 15)){ - (*(r->errHndl))(r); - } - rr = (c >> 10) & 0x1f; - gg = (c >> 5) & 0x1f; - bb = c & 0x1f; - rr = (rr * 255) / 31; - gg = (gg * 255) / 31; - bb = (bb * 255) / 31; - c = rr << 16 | gg << 8 | bb; - } - return c; -} - -void checkRect(HOSECPU_RuntimeEnvironment *r, int rxx) -{ - char c = 0; - int i; - if (r->ireg[rxx + 0] <= 0 || r->ireg[rxx + 0] > mainWindow.xsize){ - c = 1; - } - if (r->ireg[rxx + 1] <= 0 || r->ireg[rxx + 1] > mainWindow.ysize){ - c = 1; - } - if (r->ireg[rxx + 2] < 0 || r->ireg[rxx + 2] >= mainWindow.xsize){ - c = 1; - } - if (r->ireg[rxx + 3] < 0 || r->ireg[rxx + 3] >= mainWindow.ysize){ - c = 1; - } - i = r->ireg[rxx + 2] + r->ireg[rxx + 0]; - if (i <= 0 || i > mainWindow.xsize){ - c = 1; - } - i = r->ireg[rxx + 1] + r->ireg[rxx + 3]; - if (i <= 0 || i > mainWindow.ysize){ - c = 1; - } - if (c != 0){ - (*(r->errHndl))(r); - } - return; +#include "osecpu.h" + +void putOsaskChar(int c, HOSECPU_RuntimeEnvironment *r) +{ + if (0x10 <= c && c <= 0x1f){ + c = "0123456789ABCDEF"[c & 0x0f]; + } + putchar(c); + r->lastConsoleChar = c; + return; +} + +void checkString(HOSECPU_RuntimeEnvironment *r, int rxx, int pxx) +{ + char c = 0; + if (r->preg[pxx].typ != 0x03){ + c = 1; + } + if (r->preg[pxx].p < r->preg[pxx].p0){ + c = 1; + } + if (r->ireg[rxx] < 0){ + c = 1; + } + if (r->preg[pxx].p + r->ireg[rxx] > r->preg[pxx].p1){ + c = 1; + } + if (c != 0){ + (*(r->errHndl))(r); + } + return; +} + +int loadColor(HOSECPU_RuntimeEnvironment *r, int rxx) +{ + int c, m, rr, gg, bb; + c = r->ireg[rxx]; + m = r->ireg[0x31] & 0x0c; + if (m == 0x04) { + if (c < -1 || c > 7){ + (*(r->errHndl))(r); + } + c = iColor1[c & 0x07]; + } + if (m == 0x08) { + // 00, 24, 48, 6d, 91, b6, da, ff + if (c < 0 || c >= (1 << 9)){ + (*(r->errHndl))(r); + } + rr = (c >> 6) & 0x07; + gg = (c >> 3) & 0x07; + bb = c & 0x07; + rr = (rr * 255) / 7; + gg = (gg * 255) / 7; + bb = (bb * 255) / 7; + c = rr << 16 | gg << 8 | bb; + } + if (m == 0x0c) { + // 00, 08, 10, 18, 20, 29, 31, 39, + // 41, 4a, 52, 5a, 62, 6a, 73, 7b, + // 83, 8b, 94, 9c, a4, ac, b4, bd, + // c5, cd, d5, de, e6, ee, f6, ff + if (c < 0 || c >= (1 << 15)){ + (*(r->errHndl))(r); + } + rr = (c >> 10) & 0x1f; + gg = (c >> 5) & 0x1f; + bb = c & 0x1f; + rr = (rr * 255) / 31; + gg = (gg * 255) / 31; + bb = (bb * 255) / 31; + c = rr << 16 | gg << 8 | bb; + } + return c; +} + +void checkRect(HOSECPU_RuntimeEnvironment *r, int rxx) +{ + char c = 0; + int i; + if (r->ireg[rxx + 0] <= 0 || r->ireg[rxx + 0] > mainWindow.xsize){ + c = 1; + } + if (r->ireg[rxx + 1] <= 0 || r->ireg[rxx + 1] > mainWindow.ysize){ + c = 1; + } + if (r->ireg[rxx + 2] < 0 || r->ireg[rxx + 2] >= mainWindow.xsize){ + c = 1; + } + if (r->ireg[rxx + 3] < 0 || r->ireg[rxx + 3] >= mainWindow.ysize){ + c = 1; + } + i = r->ireg[rxx + 2] + r->ireg[rxx + 0]; + if (i <= 0 || i > mainWindow.xsize){ + c = 1; + } + i = r->ireg[rxx + 1] + r->ireg[rxx + 3]; + if (i <= 0 || i > mainWindow.ysize){ + c = 1; + } + if (c != 0){ + (*(r->errHndl))(r); + } + return; } \ No newline at end of file -- 2.11.0