From: Jonathan Campbell Date: Thu, 21 Apr 2016 13:31:23 +0000 (-0700) Subject: replace inline asm with _fmemcpy to copy ROM font char. X-Git-Url: http://4ch.mooo.com/gitweb/?a=commitdiff_plain;h=9b04963a6305b545154a2e962e89e7a80de28752;p=16.git replace inline asm with _fmemcpy to copy ROM font char. add reminder that it might be faster for modexDrawChar to point directly at ROM font char. the reason for replacing the inline assembly is that the original code acted without saving/restoring CPU registers that the C compiler optimization stage assumes holds results from previous C compiler generated code. corruptiong the optimizer's expectations is the reason why all code using modex (and assuming things about DS and ES) is the reason all game code was blowing up. this fix makes things stable again. --- diff --git a/pcx2vrl b/pcx2vrl index 3d9ac6e6..06179c75 100755 Binary files a/pcx2vrl and b/pcx2vrl differ diff --git a/pcxsscut b/pcxsscut index d743ac3b..2ce56d28 100755 Binary files a/pcxsscut and b/pcxsscut differ diff --git a/src/lib/modex16.c b/src/lib/modex16.c index 79a03cf3..20c468e2 100755 --- a/src/lib/modex16.c +++ b/src/lib/modex16.c @@ -903,23 +903,11 @@ void modexprint(page_t *page, word x, word y, word t, word col, word bgcol, cons y += 8; continue; } - //load the letter 'A' - __asm { - MOV DI, addr - MOV SI, o - MOV ES, s - SUB AH, AH - MOV AL, c ; the letter - MOV CX, w - MUL CX - ADD SI, AX ;the address of charcter - L1: MOV AX, ES:SI - MOV DS:DI, AX - INC SI - INC DI - DEC CX - JNZ L1 - } + + // load the character into romFontsData.l + // no need for inline assembly! + // NTS: It might even be faster to just let the modexDrawChar point directly at ROM font than to copy per char! --J.C. + _fmemcpy(romFontsData.l,MK_FP(s,o)/*ROM font location*/,w/*char size*/); modexDrawChar(page, x_draw/*for mode X planar use*/, t, col, bgcol, addrr); x_draw += 8; /* track X for edge of screen */ addrr += 2; /* move 8 pixels over (2 x 4 planar pixels per byte) */ diff --git a/vrl2vrs b/vrl2vrs index acdd4bda..cee2d1d5 100755 Binary files a/vrl2vrs and b/vrl2vrs differ diff --git a/vrsdump b/vrsdump index 8ba0497d..a75a903a 100755 Binary files a/vrsdump and b/vrsdump differ