Annotation of frontvm/hardware/fe2.c, revision 1.1.1.2

1.1       root        1: 
                      2: #include <SDL/SDL.h>
                      3: #include <SDL/SDL_endian.h>
                      4: 
                      5: #include "main.h"
                      6: #include "configuration.h"
                      7: #include "file.h"
                      8: #include "hostcall.h"
1.1.1.2 ! root        9: #include "../m68000.h"
1.1       root       10: #include "memAlloc.h"
                     11: #include "misc.h"
                     12: #include "screen.h"
                     13: #include "audio.h"
                     14: #include "input.h"
                     15: #include "fe2.h"
                     16: 
                     17: unsigned long logscreen, logscreen2, physcreen, physcreen2;
                     18: 
                     19: static const unsigned char font_bmp[] = {
                     20:        0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2,0x80,0x80,0x80,0x80,0x80,0x0,
                     21:        0x80,0x0,0x0,0x2,0xa0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x4,0x0,0x50,
                     22:        0xf8,0x50,0x50,0xf8,0x50,0x0,0x0,0x6,0x20,0xf0,0xa0,0xa0,0xa0,0xa0,0xf0,0x20,
                     23:        0x0,0x5,0x0,0xc8,0xd8,0x30,0x60,0xd8,0x98,0x0,0x0,0x6,0xa0,0x0,0xe0,0xa0,
                     24:        0xa0,0xa0,0xe0,0x0,0x0,0x4,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2,
                     25:        0xc0,0x80,0x80,0x80,0x80,0x80,0x80,0xc0,0x0,0x3,0xc0,0x40,0x40,0x40,0x40,0x40,
                     26:        0x40,0xc0,0x0,0x3,0x0,0x0,0x20,0xf8,0x50,0xf8,0x20,0x0,0x0,0x6,0x0,0x0,
                     27:        0x40,0xe0,0x40,0x0,0x0,0x0,0x0,0x4,0x0,0x0,0x0,0x0,0x0,0x0,0x80,0x80,
                     28:        0x0,0x2,0x0,0x0,0x0,0xc0,0x0,0x0,0x0,0x0,0x0,0x3,0x0,0x0,0x0,0x0,
                     29:        0x0,0x0,0x80,0x0,0x0,0x2,0x0,0x8,0x18,0x30,0x60,0xc0,0x80,0x0,0x0,0x6,
                     30:        0xe0,0xa0,0xa0,0xa0,0xa0,0xa0,0xe0,0x0,0x0,0x4,0x40,0xc0,0x40,0x40,0x40,0x40,
                     31:        0xe0,0x0,0x0,0x4,0xe0,0x20,0x20,0xe0,0x80,0x80,0xe0,0x0,0x0,0x4,0xe0,0x20,
                     32:        0x20,0xe0,0x20,0x20,0xe0,0x0,0x0,0x4,0x80,0x80,0xa0,0xa0,0xe0,0x20,0x20,0x0,
                     33:        0x0,0x4,0xe0,0x80,0x80,0xe0,0x20,0x20,0xe0,0x0,0x0,0x4,0xe0,0x80,0x80,0xe0,
                     34:        0xa0,0xa0,0xe0,0x0,0x0,0x4,0xe0,0x20,0x20,0x20,0x20,0x20,0x20,0x0,0x0,0x4,
                     35:        0xe0,0xa0,0xa0,0xe0,0xa0,0xa0,0xe0,0x0,0x0,0x4,0xe0,0xa0,0xa0,0xe0,0x20,0x20,
                     36:        0xe0,0x0,0x0,0x4,0x0,0x0,0x0,0x80,0x0,0x80,0x0,0x0,0x0,0x2,0x0,0x0,
                     37:        0x0,0x80,0x0,0x0,0x80,0x80,0x0,0x2,0xe0,0x0,0xe0,0xa0,0xa0,0xa0,0xa0,0x0,
                     38:        0x0,0x4,0x0,0x0,0xe0,0x0,0xe0,0x0,0x0,0x0,0x0,0x4,0xc0,0x0,0xe0,0xa0,
                     39:        0xe0,0x80,0xe0,0x0,0x0,0x4,0xe0,0x20,0x20,0xe0,0x80,0x0,0x80,0x0,0x0,0x4,
                     40:        0xfe,0x82,0xba,0xa2,0xba,0x82,0xfe,0x0,0x0,0x8,0xf0,0x90,0x90,0x90,0xf0,0x90,
                     41:        0x90,0x0,0x0,0x5,0xf0,0x90,0x90,0xf8,0x88,0x88,0xf8,0x0,0x0,0x6,0xe0,0x80,
                     42:        0x80,0x80,0x80,0x80,0xe0,0x0,0x0,0x4,0xf8,0x48,0x48,0x48,0x48,0x48,0xf8,0x0,
                     43:        0x0,0x6,0xf0,0x80,0x80,0xe0,0x80,0x80,0xf0,0x0,0x0,0x5,0xf0,0x80,0x80,0xe0,
                     44:        0x80,0x80,0x80,0x0,0x0,0x4,0xf0,0x80,0x80,0x80,0xb0,0x90,0xf0,0x0,0x0,0x5,
                     45:        0x90,0x90,0x90,0xf0,0x90,0x90,0x90,0x0,0x0,0x5,0xe0,0x40,0x40,0x40,0x40,0x40,
                     46:        0xe0,0x0,0x0,0x4,0xf0,0x20,0x20,0x20,0x20,0x20,0xe0,0x0,0x0,0x4,0x90,0xb0,
                     47:        0xe0,0xc0,0xe0,0xb0,0x90,0x0,0x0,0x5,0x80,0x80,0x80,0x80,0x80,0x80,0xe0,0x0,
                     48:        0x0,0x4,0x88,0xd8,0xf8,0xa8,0x88,0x88,0x88,0x0,0x0,0x6,0x90,0xd0,0xf0,0xb0,
                     49:        0x90,0x90,0x90,0x0,0x0,0x5,0xf0,0x90,0x90,0x90,0x90,0x90,0xf0,0x0,0x0,0x5,
                     50:        0xf0,0x90,0x90,0xf0,0x80,0x80,0x80,0x0,0x0,0x5,0xf0,0x90,0x90,0x90,0x90,0xb0,
                     51:        0xf0,0x18,0x0,0x5,0xf0,0x90,0x90,0xf0,0xe0,0xb0,0x90,0x0,0x0,0x5,0xf0,0x80,
                     52:        0x80,0xf0,0x10,0x10,0xf0,0x0,0x0,0x5,0xe0,0x40,0x40,0x40,0x40,0x40,0x40,0x0,
                     53:        0x0,0x3,0x90,0x90,0x90,0x90,0x90,0x90,0xf0,0x0,0x0,0x5,0x90,0x90,0x90,0xb0,
                     54:        0xe0,0xc0,0x80,0x0,0x0,0x5,0x88,0x88,0x88,0xa8,0xf8,0xd8,0x88,0x0,0x0,0x6,
                     55:        0x88,0xd8,0x70,0x20,0x70,0xd8,0x88,0x0,0x0,0x6,0x90,0x90,0x90,0xf0,0x20,0x20,
                     56:        0x20,0x0,0x0,0x5,0xf0,0x10,0x30,0x60,0xc0,0x80,0xf0,0x0,0x0,0x5,0xa0,0x0,
                     57:        0xa0,0xa0,0xa0,0xa0,0xe0,0x0,0x0,0x4,0x0,0x80,0xc0,0x60,0x30,0x18,0x8,0x0,
                     58:        0x0,0x6,0xe0,0xa0,0xa0,0xe0,0xa0,0xa0,0xe0,0x80,0x80,0x4,0xe0,0xa0,0xe0,0x0,
                     59:        0x0,0x0,0x0,0x0,0x0,0x4,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xf8,0x0,0x6,
                     60:        0xa0,0x0,0xe0,0x20,0xe0,0xa0,0xe0,0x0,0x0,0x4,0x0,0x0,0xe0,0x20,0xe0,0xa0,
                     61:        0xe0,0x0,0x0,0x4,0x80,0x80,0xe0,0xa0,0xa0,0xa0,0xe0,0x0,0x0,0x4,0x0,0x0,
                     62:        0xc0,0x80,0x80,0x80,0xc0,0x0,0x0,0x3,0x20,0x20,0xe0,0xa0,0xa0,0xa0,0xe0,0x0,
                     63:        0x0,0x4,0x0,0x0,0xe0,0xa0,0xe0,0x80,0xe0,0x0,0x0,0x4,0xc0,0x80,0x80,0xc0,
                     64:        0x80,0x80,0x80,0x0,0x0,0x3,0x0,0x0,0xe0,0xa0,0xa0,0xa0,0xe0,0x20,0xe0,0x4,
                     65:        0x80,0x80,0xe0,0xa0,0xa0,0xa0,0xa0,0x0,0x0,0x4,0x80,0x0,0x80,0x80,0x80,0x80,
                     66:        0x80,0x0,0x0,0x2,0x40,0x0,0x40,0x40,0x40,0x40,0x40,0xc0,0x0,0x3,0x80,0x80,
                     67:        0xb0,0xe0,0xe0,0xb0,0x90,0x0,0x0,0x5,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x0,
                     68:        0x0,0x2,0x0,0x0,0xf8,0xa8,0xa8,0xa8,0xa8,0x0,0x0,0x6,0x0,0x0,0xe0,0xa0,
                     69:        0xa0,0xa0,0xa0,0x0,0x0,0x4,0x0,0x0,0xe0,0xa0,0xa0,0xa0,0xe0,0x0,0x0,0x4,
                     70:        0x0,0x0,0xe0,0xa0,0xa0,0xa0,0xe0,0x80,0x80,0x4,0x0,0x0,0xe0,0xa0,0xa0,0xa0,
                     71:        0xe0,0x20,0x30,0x4,0x0,0x0,0xc0,0x80,0x80,0x80,0x80,0x0,0x0,0x3,0x0,0x0,
                     72:        0xc0,0x80,0xc0,0x40,0xc0,0x0,0x0,0x3,0x80,0x80,0xc0,0x80,0x80,0x80,0xc0,0x0,
                     73:        0x0,0x3,0x0,0x0,0xa0,0xa0,0xa0,0xa0,0xe0,0x0,0x0,0x4,0x0,0x0,0xa0,0xa0,
                     74:        0xe0,0xc0,0x80,0x0,0x0,0x4,0x0,0x0,0x88,0xa8,0xf8,0xd8,0x88,0x0,0x0,0x6,
                     75:        0x0,0x0,0xa0,0xe0,0x40,0xe0,0xa0,0x0,0x0,0x4,0x0,0x0,0xa0,0xa0,0xa0,0xa0,
                     76:        0xe0,0x20,0xe0,0x4,0x0,0x0,0xf0,0x30,0x60,0xc0,0xf0,0x0,0x0,0x5,0x81,0x8d,
                     77:        0xe1,0xa0,0xa0,0xa0,0xa0,0x0,0x0,0x9,0x2,0x1a,0xc2,0x80,0xc0,0x40,0xc0,0x0,
                     78:        0x0,0x8,0xfe,0xfc,0xf8,0xfc,0xfe,0xdf,0x8e,0x4,0x0,0x7,0x7f,0x3f,0x1f,0x3f,
                     79:        0x7f,0xfb,0x71,0x20,0x0,0x8,0x4,0x8e,0xdf,0xfe,0xfc,0xf8,0xfc,0xfe,0x0,0x8,
                     80:        0x20,0x71,0xfb,0x7f,0x3f,0x1f,0x3f,0x7f,0x0,0x7,0xff,0x81,0x81,0x81,0x81,0x81,
                     81:        0x81,0xff,0x0,0x9,0x0,0x0,0xe0,0x80,0x80,0x80,0xe0,0x40,0xc0,0x4,0x60,0x0,
                     82:        0xe0,0xa0,0xe0,0x80,0xe0,0x0,0x0,0x4,0xc0,0x0,0xa0,0xa0,0xa0,0xa0,0xe0,0x0,
                     83:        0x0,0x4,0x40,0xa0,0x40,0x40,0x40,0x40,0x40,0x0,0x0,0x4,0x40,0xa0,0xe0,0x20,
                     84:        0xe0,0xa0,0xe0,0x0,0x0,0x4,0x40,0xa0,0xe0,0xa0,0xa0,0xa0,0xe0,0x0,0x0,0x4,
                     85:        0x40,0xa0,0xe0,0xa0,0xe0,0x80,0xe0,0x0,0x0,0x4,0xe0,0x0,0xa0,0xa0,0xa0,0xa0,
                     86:        0xe0,0x0,0x0,0x4,0xc0,0x0,0xe0,0x20,0xe0,0xa0,0xe0,0x0,0x0,0x4,0xe0,0xa0,
                     87:        0xa0,0xa0,0xe0,0xa0,0xa0,0x0,0x0,0x4,0xc0,0xa0,0xa0,0xc0,0xa0,0xa0,0xc0,0x0,
                     88:        0x0,0x4,0xe0,0x80,0x80,0x80,0x80,0x80,0xe0,0x0,0x0,0x4,0xc0,0xa0,0xa0,0xa0,
                     89:        0xa0,0xa0,0xc0,0x0,0x0,0x4,0xe0,0x80,0x80,0xe0,0x80,0x80,0xe0,0x0,0x0,0x4,
                     90:        0xe0,0x80,0x80,0xe0,0x80,0x80,0x80,0x0,0x0,0x4
                     91: };
                     92: 
                     93: static int DrawChar (int col, int xoffset, char *screen, int chr)
                     94: {
                     95:        const char *font_pos;
                     96:        int i;
                     97:        
                     98:        font_pos = font_bmp;
                     99:        font_pos += (chr&0xff)*10;
                    100:        screen += xoffset;
                    101:        
1.1.1.2 ! root      102:        if (xoffset < 0) {
        !           103:                font_pos += 9;
        !           104:                return xoffset + *font_pos;
        !           105:        }
        !           106:        
1.1       root      107:        for (i=0; i<8; i++) {
                    108:                if (*font_pos & 0x80) *screen = col;
                    109:                screen++;
                    110:                if (*font_pos & 0x40) *screen = col;
                    111:                screen++;
                    112:                if (*font_pos & 0x20) *screen = col;
                    113:                screen++;
                    114:                if (*font_pos & 0x10) *screen = col;
                    115:                screen++;
                    116:                if (*font_pos & 0x8) *screen = col;
                    117:                screen++;
                    118:                if (*font_pos & 0x4) *screen = col;
                    119:                screen++;
                    120:                if (*font_pos & 0x2) *screen = col;
                    121:                screen++;
                    122:                if (*font_pos & 0x1) *screen = col;
                    123:                screen++;
                    124:                font_pos++;
                    125:                screen += SCREENBYTES_LINE-8;
                    126:        }
                    127:        /* width of character */
                    128:        font_pos++;
                    129:        i = *font_pos;
                    130:        return xoffset + i;
                    131: }
                    132: 
                    133: int DrawStr (int xpos, int ypos, int col, unsigned char *str, bool shadowed)
                    134: {
                    135:        int x, y, chr;
                    136:        char *screen;
                    137: 
                    138:        x = xpos;
                    139:        y = ypos;
                    140: 
                    141:        if ((y > 192) || (y<0)) return x;
                    142: set_line:
                    143:        screen = LOGSCREEN2;
                    144:        screen += SCREENBYTES_LINE * y;
                    145: 
                    146:        while (*str) {
                    147:                chr = *(str++);
                    148:                
                    149:                if (chr < 0x1e) {
                    150:                        if (chr == '\r') {
                    151:                                y += 10;
                    152:                                x = xpos;
                    153:                                goto set_line;
                    154:                        }
                    155:                        else if (chr == 1) col = *(str++);
                    156:                        continue;
                    157:                } else if (chr == 0x1e) {
                    158:                        /* read new xpos */
                    159:                        x = *(str++);
                    160:                        x *= 2;
                    161:                        continue;
                    162:                } else if (chr < 0x20) {
                    163:                        /* Read new position */
                    164:                        x = *(str++);
                    165:                        x *= 2;
                    166:                        y = *(str++);
                    167:                        goto set_line;
                    168:                }
                    169:                
                    170:                if (x > 316) continue;
                    171: 
                    172:                if (shadowed) DrawChar (0, x+1, screen+SCREENBYTES_LINE, chr-0x20);
                    173:                x = DrawChar (col, x, screen, chr-0x20);
                    174:        }
                    175: 
                    176:        return x;
                    177: }
                    178: 
                    179: #define SWAP(a,b)      do { tmp=(a); (a)=(b); (b)=tmp; } while (0);
                    180: 
                    181: static void draw_hline (int sx, int ex, int sy, int col)
                    182: {
                    183:        char *pix;
                    184: 
                    185:        pix = LOGSCREEN2 + (SCREENBYTES_LINE * sy) + sx;
                    186: 
                    187:        for (; sx<=ex; sx++) {
                    188:                *pix = col;
                    189:                pix++;
                    190:        }
                    191: }
                    192: 
                    193: static void put_pix (int x, int y, int col)
                    194: {
                    195:        char *pix;
                    196: 
                    197:        pix = LOGSCREEN2 + (SCREENBYTES_LINE * y) + x;
                    198: 
                    199:        *pix = col;
                    200: }
                    201: 
                    202: void DrawTriangle (int Ax, int Ay, int Bx, int By, int Cx, int Cy, int col)
                    203: {
                    204:        float dx1, dx2, dx3;
                    205:        int tmp;
                    206:        float Sx, Sy, Ex;
                    207:        
                    208:        /* sort so A is lowest y coord, C highest */
                    209:        if (Ay > Cy) { SWAP (Ax,Cx); SWAP (Ay,Cy); }
                    210:        if (By > Cy) { SWAP (Bx,Cx); SWAP (By,Cy); }
                    211:        if (Ay > By) { SWAP (Ax,Bx); SWAP (Ay,By); }
                    212: 
                    213:        if ((Ay == By) && (Ax > Bx)) { SWAP (Ax,Bx); SWAP (Ay,By); }
                    214:        
                    215:        if (By - Ay > 0) dx1 = (Bx - Ax)/(float)(By - Ay); else dx1 = Bx - Ax;
                    216:        if (Cy - Ay > 0) dx2 = (Cx - Ax)/(float)(Cy - Ay); else dx2 = Cx - Ax;
                    217:        if (Cy - By > 0) dx3 = (Cx - Bx)/(float)(Cy - By); else dx3 = Cx - Bx;
                    218:        
                    219:        
                    220:        Ex = Sx = Ax;
                    221:        Sy = Ay;
                    222:        
                    223:        if (dx1 > dx2) {
                    224:                for (; Sy < By; Sy++,Sx+=dx2,Ex+=dx1)
                    225:                        draw_hline (Sx, Ex, Sy, col);
                    226:                Ex = Bx;
                    227:                for (; Sy <= Cy; Sy++,Sx+=dx2,Ex+=dx3)
                    228:                        draw_hline (Sx, Ex, Sy, col);
                    229:        } else {
                    230:                for (; Sy < By; Sy++,Sx+=dx1,Ex+=dx2)
                    231:                        draw_hline (Sx, Ex, Sy, col);
                    232:                Sx = Bx;
                    233:                Sy = By;
                    234:                for (; Sy <= Cy; Sy++,Sx+=dx3,Ex+=dx2)
                    235:                        draw_hline (Sx, Ex, Sy, col);
                    236:        }
                    237:        
                    238:        //put_pix (Ax, Ay, 1);
                    239:        //put_pix (Bx, By, 1);
                    240:        //put_pix (Cx, Cy, 1);
                    241: }
                    242: 
                    243: void DrawPoly (struct Point *pt, int len, int col)
                    244: {
                    245:        struct Point p1, p2, p3;
                    246:        int i;
                    247: 
                    248:        p1 = pt[0];
                    249:        for (i=1; i<len-1; i++) {
                    250:                p2 = pt[i];
                    251:                p3 = pt[i+1];
                    252:                DrawTriangle (p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, col);
                    253:                p1 = p2;
                    254:        }
                    255: }
                    256: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.