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

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

unix.superglobalmegacorp.com

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