X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=asmyt.c;h=d8447479a20927cf9c9ae4603dbfb9997d9c9827;hb=646d04f51c8fd06e93b6517334bcac1e9b7157f2;hp=bc5818ba4f73b8bca837917b27327998ab1604f2;hpb=2cf7e817358bc59fe630719aef5f143cfa191a88;p=plz.git diff --git a/asmyt.c b/asmyt.c index bc5818b..d844747 100755 --- a/asmyt.c +++ b/asmyt.c @@ -1,182 +1,127 @@ -#include "asmyt.h" -// __asm{ -// PUBLIC C plzline, C setplzparas, C psini, C lsini4, C lsini16 -// -// LABEL psini BYTE -// INCLUDE 'psini.inc' -// ; db 16384 dup(?) -// -// LABEL lsini4 WORD -// INCLUDE 'lsini4.inc' -// ; db 16384 dup(?) -// -// LABEL lsini16 WORD -// INCLUDE 'lsini16.inc' -// ; db 16384 dup(?) -// } - -int ccc; - -word set_plzstart(word start) -{ -__asm{ - mov dx, 3d4h - mov al, 18h ; linecompare - mov ah, [Byte PTR start] - out dx, ax - mov al, 07h - mov ah, [Byte PTR start+1] - shl ah, 1d - shl ah, 1d - shl ah, 1d - shl ah, 1d - and ah, 10h - or ah, 0fh - out dx, ax ; 8th bit -} - return start; -} -/* -int plzline(int y, int vseg) -{ - // vseg represented a segment, so multiply by sixteen (shift left by 4) - // to convert into an offset. - var nVgaYOffset = vseg * 16; - - var cccTable = - [ - 3,2,1,0,7,6,5,4,11,10,9,8,15,14,13,12,19,18,17,16,23,22,21,20,27,26,25,24,31,30,29,28,35,34,33,32,39,38,37,36,43,42,41,40,47,46,45,44,51,50,49,48,55,54,53,52,59,58,57,56,63,62,61,60,67,66,65,64,71,70,69,68,75,74,73,72,79,78,77,76,83,82,81,80 - ]; - var nCount = 84; - - var ah = 0; - var al = 0; - var eax = 0; - - for (var nIndex = 0; nIndex < nCount; nIndex++) - { - var ccc = cccTable[nIndex]; - - if ((ccc & 1) == 1) - { - var nByteOffset = 0; - var bx = 0; - - nByteOffset = (y * 2) + anSelfModifyOffsets_ReadWord((2 * 84) + ccc); - nByteOffset &= 0xFFFF; - bx = psini_ReadWord(nByteOffset); - - nByteOffset = bx + anSelfModifyOffsets_ReadWord((1 * 84) + ccc); - nByteOffset &= 0xFFFF; - ah = psini_ReadByte(nByteOffset); - - nByteOffset = (y * 2) + anSelfModifyOffsets_ReadWord((4 * 84) + ccc); - nByteOffset &= 0xFFFF; - bx = psini_ReadWord(nByteOffset); - - nByteOffset = bx + (y * 2) + anSelfModifyOffsets_ReadWord((3 * 84) + ccc); - nByteOffset &= 0xFFFF; - ah += psini_ReadByte(nByteOffset); - ah &= 0xFF; - } - else - { - var nByteOffset = 0; - var bx = 0; - - nByteOffset = (y * 2) + anSelfModifyOffsets_ReadWord((2 * 84) + ccc); - nByteOffset &= 0xFFFF; - bx = psini_ReadWord(nByteOffset); - - nByteOffset = bx + anSelfModifyOffsets_ReadWord((1 * 84) + ccc); - nByteOffset &= 0xFFFF; - al = psini_ReadByte(nByteOffset); - - nByteOffset = (y * 2) + anSelfModifyOffsets_ReadWord((4 * 84) + ccc); - nByteOffset &= 0xFFFF; - bx = psini_ReadWord(nByteOffset); - - nByteOffset = bx + (y * 2) + anSelfModifyOffsets_ReadWord((3 * 84) + ccc); - nByteOffset &= 0xFFFF; - al += psini_ReadByte(nByteOffset); - al &= 0xFF; - } - - if ((ccc & 3) == 2) - { - eax = (ah << 8) | (al << 0); - eax <<= 16; - } - - if ((ccc & 3) == 0) - { - eax |= (ah << 8) | (al << 0); - - VGA_WriteDword(nVgaYOffset + ccc, eax); - } - } - - return 0; -} - -*/ -int setplzparas(int c1, int c2, int c3, int c4) -{ -// static word psini; -// static word lsini4; -// static word lsini16; - __asm{ -psini WORD .LABEL -'psini.inc' INCLUDE - -lsini4 WORD .LABEL -'lsini4.inc' INCLUDE - -lsini16 WORD .LABEL -'lsini16.inc' INCLUDE - - IRP ccc, <0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83> - mov ax, [c1] - add ax, OFFSET psini+ccc*8 - mov [word (cs:lc1_&ccc)], ax - mov ax, [c2] - shl ax, 1d - add ax, OFFSET lsini16-ccc*8+80*8 - mov [word (cs:lc2_&ccc)], ax - mov ax, [c3] - add ax, OFFSET psini-ccc*4+80*4 - mov [word (cs:lc3_&ccc)], ax - mov ax, [c4] - shl ax, 1d - add ax, OFFSET lsini4+ccc*32 - mov [word (cs:lc4_&ccc)], ax - ENDM - ret - } - return 0; -} -/* var psiniOffset = 0; - var lsini16Offset = lsini16_GetOffset(); - var lsini4Offset = lsini4_GetOffset(); - - for (var ccc = 0; ccc < 84; ccc++) - { - var lc1 = c1 + psiniOffset + (ccc * 8); - lc1 &= 0xFFFF; - anSelfModifyOffsets_WriteWord((1 * 84) + ccc, lc1); - - var lc2 = (c2 * 2) + lsini16Offset - (ccc * 8) + (80 * 8); - lc2 &= 0xFFFF; - anSelfModifyOffsets_WriteWord((2 * 84) + ccc, lc2); - - var lc3 = c3 + psiniOffset - (ccc * 4) + (80 * 4); - lc3 &= 0xFFFF; - anSelfModifyOffsets_WriteWord((3 * 84) + ccc, lc3); - - var lc4 = (c4 * 2) + lsini4Offset + (ccc * 32); - lc4 &= 0xFFFF; - anSelfModifyOffsets_WriteWord((4 * 84) + ccc, lc4); - } - - return 0; -}*/ +/* + * Written by Nick Kovac with minor changes by Claudio Matsuoka + */ + +#include "common.h" + +static uint16_t selfmod[5][84]; +extern char *psini; + +#define PSINI_OFFSET 0 +#define LSINI4_OFFSET 16384 +#define LSINI16_OFFSET (16384 + 2 * 8192) + + +int plzline(int y, int vseg) +{ + // vseg represented a segment, so multiply by sixteen (shift left by 4) + // to convert into an offset. + int nVgaYOffset = vseg << 4; + + int cccTable[] = { + 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12, 19, 18, + 17, 16, 23, 22, 21, 20, 27, 26, 25, 24, 31, 30, 29, 28, 35, + 34, 33, 32, 39, 38, 37, 36, 43, 42, 41, 40, 47, 46, 45, 44, + 51, 50, 49, 48, 55, 54, 53, 52, 59, 58, 57, 56, 63, 62, 61, + 60, 67, 66, 65, 64, 71, 70, 69, 68, 75, 74, 73, 72, 79, 78, + 77, 76, 83, 82, 81, 80 + }; + uint8_t ah = 0; + uint8_t al = 0; + uint16_t eax = 0; + int i; + + for (i = 0; i < 84; i++) { + int ccc = cccTable[i]; + uint16_t offs; + int bx; + + if ((ccc & 1) == 1) { + // within lsini16 + offs = (y * 2) + selfmod[2][ccc]; + bx = *(short *)&psini[offs]; + + // within psini + offs = bx + selfmod[1][ccc]; + ah = psini[offs]; + + // within lsini4 + offs = (y * 2) + selfmod[4][ccc]; + bx = *(short *)&psini[offs]; + + // within psini + offs = bx + (y * 2) + selfmod[3][ccc]; + ah += psini[offs]; + } else { + offs = (y * 2) + selfmod[2][ccc]; + bx = *(short *)&psini[offs]; + + offs = bx + selfmod[1][ccc]; + al = psini[offs]; + + offs = (y * 2) + selfmod[4][ccc]; + bx = *(short *)&psini[offs]; + + offs = bx + (y * 2) + selfmod[3][ccc]; + al += psini[offs]; + } + + if ((ccc & 3) == 2) { + eax = (ah << 8) | al; + eax <<= 8; + } + + if ((ccc & 3) == 0) { + eax |= (ah << 8) | al; +// vga_write32(nVgaYOffset + ccc, eax); + __asm { + mov [es:ccc], ax + } + } + } + + return 0; +} + +int setplzparas(int c1, int c2, int c3, int c4) +{ + int ccc; + + for (ccc = 0; ccc < 84; ccc++) { + uint16_t lc1, lc2, lc3, lc4; + + lc1 = c1 + PSINI_OFFSET + (ccc * 8); + selfmod[1][ccc] = lc1; + + lc2 = (c2 * 2) + LSINI16_OFFSET - (ccc * 8) + (80 * 8); + selfmod[2][ccc] = lc2; + + lc3 = c3 + PSINI_OFFSET - (ccc * 4) + (80 * 4); + selfmod[3][ccc] = lc3; + + lc4 = (c4 * 2) + LSINI4_OFFSET + (ccc * 32); + selfmod[4][ccc] = lc4; + } + + return 0; +} + +word set_plzstart(word start) +{ +__asm{ + mov dx, 3d4h + mov al, 18h ; linecompare + mov ah, [Byte PTR start] + out dx, ax + mov al, 07h + mov ah, [Byte PTR start+1] + shl ah, 1d + shl ah, 1d + shl ah, 1d + shl ah, 1d + and ah, 10h + or ah, 0fh + out dx, ax ; 8th bit +} + return start; +}