flat assembler
Message board for the users of flat assembler.
Index
> DOS > hi-res LFB VESA examples with user specific CRTC values |
Author |
|
Matrix 15 Sep 2004, 16:27
ihave tested your stuff, but the error was at the first line:
include "MYSTUFF.ASH" MATRIX |
|||
15 Sep 2004, 16:27 |
|
MCD 17 Sep 2004, 12:20
sorry Matrix, i forgot the "MYSTUFF.ASH" file, which is my default macro/equates and definiton file (many stuff).
I will reattach another, more complete archive with the assembled .com-file. I prefer RAR-archives. But don't be shocked if you look at the code, it uses tremendously simplified instruction mnemonics, all defined in the "MYSTUFF.ASH" file. Originally, I was just trying to shorten thos longlonglonglong MMX/SSE instructions, but it finally ended up in shortening about one half of all instructions. I use this kind of shortening only for my own code because I have great fear this may (and suretenly will) confuse others. In addition to that, it is still under construction. If you have problems reading the code, I could write it back to standard Fasm syntax.
_________________ MCD - the inevitable return of the Mad Computer Doggy -||__/ .|+-~ .|| || |
|||||||||||
17 Sep 2004, 12:20 |
|
Matrix 17 Sep 2004, 12:25
MCD wrote: sorry Matrix, i forgot the "MYSTUFF.ASH" file, which is my default macro/equates and definiton file (many stuff). Well Hy MCD, yes that was exactly was i thinking of, i could convert it back to fasm if i had some idea about that INIDX function remember this was the name. I whouldn't recommend you to use these kind of shortenings on your code, cause' you might forget the real instruction's names MATRIX |
|||
17 Sep 2004, 12:25 |
|
MCD 17 Sep 2004, 12:47
INIDX means In with Index. It is an abreviation to stuff like:
Code: out PortNumber,al in al,PortNumber+1 OutIDX works accordingly. _________________ MCD - the inevitable return of the Mad Computer Doggy -||__/ .|+-~ .|| || |
|||
17 Sep 2004, 12:47 |
|
Matrix 17 Sep 2004, 12:59
MCD wrote: INIDX means In with Index. It is an abreviation to stuff like: i see your point now, and understand you don't like to write much, but you should take care with the simplifying cause it can cause you a great headache in the near future (can or might but not necceserily) (this is wasn't really about that INIDX macro) you might not been interested in optimizing your code, but in many cases these kind of macros make it very difficult, and after a while making your code unfollowable - especially when nested things are done. ps.: i whould never use a as and, cause in microcontrollers, a is accumulator. MATRIX |
|||
17 Sep 2004, 12:59 |
|
Matrix 17 Sep 2004, 13:30
Hello again MCD,
i was just dropping by to tell that i have tested your example. it did something with my monitor, but i think this might not be your point. it started tweeking and then windows told me that the program has made an exception @ 1416:0169 MATRIX |
|||
17 Sep 2004, 13:30 |
|
MCD 17 Sep 2004, 13:32
Yes, you are right. So basically, I try to avoid those deep nested stuff
(just got to see the FasmW IDE source/includes for Win32 ). And I take much care and time to check and test those things. Just a question to your nick: Does these green vertically scrolled screen in MATRIX (the movies) run on some asian DOS versions with DBCS? (looks like being displayed on some old monochrome monitors ) I've got more good DOS tool for ya, a so called "STEX" Standard Text Mode Extension, APM standby/off-switching tools etc. they are all in the attached archive. Another general TSR thing: do you think stack switching are neccessary for software int-handlers?(hardware IRQ-handlers do need them, I know) _________________ MCD - the inevitable return of the Mad Computer Doggy -||__/ .|+-~ .|| || |
|||
17 Sep 2004, 13:32 |
|
ASHLEY4 17 Sep 2004, 18:21
? do you want a matrix screen saver for dos? .
\\\\||//// (@@) ASHLEY4. |
|||
17 Sep 2004, 18:21 |
|
MCD 22 Sep 2004, 20:06
if it is small and compatible, yes.
|
|||
22 Sep 2004, 20:06 |
|
ASHLEY4 22 Sep 2004, 21:21
Done in tasm,so needs converting.
Code: .MODEL TINY ;05/09/02 .386 .CODE ORG 100HCHRATR EQU 02H ;Character colorFALATR EQU 03H ;Falling character color; ||_____________________ Foreground color; |______________________ Background colorNEWMSK EQU 11111111B ;New column random number maskCOLVAR STRUC DB 132 DUP(0) ;Character rowSPCROW DB 132 DUP(0) ;Space rowCOLSTA DB 132 DUP(00000000B) ;Column status; |||||___________ Offset right; ||||____________ Offset left; |||_____________ Character done; ||______________ Space; |_______________ CharacterCOLVAR ENDSVARBLE STRUCSEED DD ? ;Random seedCURLOC DW ? ;Entry cursor locationVIDMOD DB ? ;Entry video modeROWCT0 DB ? ;Base 0 row countCOLCNT DW ? ;Column countCOLCT2 DW ? ;2 * column countROWCNT DW ? ;Row countVESMOD DW ? ;VESA modeCHRROW COLVAR <>VARBLE ENDSSTART: PUSH CS POP DS ;Code segment to DS PUSH CS POP ES ;Code segment to ES MOV BP,offset VARBAS ;Point to variable base CALL RNDMIZ ;Randomize pseudo-random sequence MOV AX,4F00H MOV DI,offset SCRBUF ;Point to VESA buffer INT 10H ;Get SVGA info MOV SI,DI ;VESA buffer pointer to SI MOV EAX,[SI] ;Get signature CMP EAX,'ASEV' ;VESA? JNZ SHORT NOVESA ;No LDS SI,[SI+0EH] ;Get mode block pointer MOV BX,10CH ;132 x 60 mode index MOV CX,132 ;Column count MOV DX,60 ;Row count CALL FNDMOD ;VESA supports 132 x 60 mode? JZ short MODFND ;Yes DEC BX ;132 x 50 mode index (10BH) MOV DL,50 ;Row count CALL FNDMOD ;VESA supports 132 x 50 mode? JZ short MODFND ;Yes DEC BX ;132 x 43 mode index (10AH) MOV DL,43 ;Row count CALL FNDMOD ;VESA supports 132 x 43 mode? JZ short MODFND ;Yes DEC BX ;132 x 25 mode index (109H) MOV DL,25 ;Row count CALL FNDMOD ;VESA supports 132 x 43 mode? JZ short MODFND ;Yes DEC BX ;80 x 60 mode index (108H) MOV CX,80 ;Column count MOV DL,60 ;Row count CALL FNDMOD ;VESA supports 80 x 60 mode? JZ short MODFND ;YesNOVESA: XOR BX,BX ;Null mode index MOV CX,80 ;Column count MOV DX,25 ;Row countMODFND: MOV [BP+VESMOD],BX ;Store VESA mode MOV [BP+COLCNT],CX ;Store column count ADD CX,CX MOV [BP+COLCT2],CX ;Store column count*2 MOV [BP+ROWCNT],DX ;Store row count DEC DX MOV [BP+ROWCT0],DL ;Store base 0 row count PUSH CS POP DS ;Code segment to DS PUSH 0B800H POP ES ;Screen segment to ES MOV AX,11 INT 33H ;Clear mouse motion counters CALL GETCUR ;Get cursor offset MOV [BP+CURLOC],AX ;Store cursor offset CALL SAVSCR ;Save user's screen MOV AH,0FH INT 10H ;Get video mode MOV [BP+VIDMOD],AL ;Store video mode MOV AX,4F02H MOV BX,[BP+VESMOD] ;Get VESA mode index TEST BX,BX ;Null video mode? JZ short DEFMOD ;Yes INT 10H ;Set VESA text modeDEFMOD: CALL CUROFF ;Move cursor off screen MOV AX,CHRATR*256+' ' MOV CX,[BP+COLCNT] ;Get column count IMUL CX,[BP+ROWCNT] ;Calculate screen character count XOR DI,DI REP STOSW ;Clear largest possible screenUPDSCR: MOV CX,[BP+COLCNT] ;Get column count XOR DX,DX ;Clear column offset LEA SI,[BP+CHRROW] ;Point to column statusDOCOLM: MOV BL,[SI+COLSTA] ;Get column status TEST BL,BL ;Character or empty column? JZ short NEWCHR ;Empty JS short ADJCHR ;Character TEST BL,01000000B ;Space column? JZ TSTDON ;No CMP byte ptr[SI+SPCROW],8 ;Spaces at least 8 rows down? JB ADJSPC ;NoNEWCHR: CALL RANDOM ;Get random number TEST AL,NEWMSK ;Random number & mask = 0? JNZ short TTSSPC ;No CALL RNDCHR ;Get random character OR BL,10000000B ;Set "character" flag MOV AH,FALATR ;Falling character attribute MOV DI,DX ;Column offset to DI STOSW ;Store initial characterTTSSPC: JMP TSTSPCADJCHR: MOV AL,[SI] ;Get row MOVZX DI,AL ;Row to DI IMUL DI,[BP+COLCT2] ;Calculate row offset ADD DI,DX ;Form screen pointer CMP AL,[BP+ROWCT0] ;At or past bottom row? PUSHF ;Save Z flag JB short ADJCH1 ;No AND BL,01111111B ;Clear "character" flag OR BL,00100000B ;Set "character done" flag MOV byte ptr[SI],0 ;Clear rowADJCH1: TEST BL,00011000B ;Offset left or right? JZ short NOTOFS ;No TEST BL,00010000B ;Offset left? JZ short OFSRHT ;No MOV AX,ES:[DI-2] ;Get offset left character MOV ES:byte ptr[DI-2],' ' ;Erase offset left character JMP short NXTCHROFSRHT: MOV AX,ES:[DI+2] ;Get offset right character MOV ES:byte ptr[DI+2],' ' ;Erase offset right character JMP short NXTCHRNOTOFS: MOV AH,CHRATR ;Normal character color CALL RNDATR ;Invert "intense" bit if rand mod 32=0 MOV ES:[DI+1],AH ;Store character attributeNXTCHR: POPF ;In bottom row? JAE short NEWSPC ;Yes TEST BL,00011000B ;Offset left or right? JZ short NOTOF1 ;No MOV ES:[DI],AX ;Store new character AND BL,11100111B ;Clear "offset" flags JMP short NEWSPCNOTOF1: MOV BH,[SI] ;Get row CMP BH,4 ;< row 4? JB short DRPCHR ;Yes CMP BH,[BP+ROWCT0] ;last row? JAE short DRPCHR ;Yes PUSH AX ;Save character & attribute CALL RANDOM ;Get random number TEST AL,00011111B ;Mod 32 = 0? POP AX ;Restore character & attribute JNZ short DRPCHR ;No MOV AL,ES:[DI] ;Get current character MOV AH,FALATR xor 00001000B ;Falling char attr with "intense" bit MOV BH,' ' TEST DX,DX ;Column 0? JZ short TRYRHT ;Yes CMP ES:[DI-2],BH ;Space in column to left? JNZ short TRYRHT ;No PUSH DI ;Save screen pointer SUB DI,[BP+COLCT2] ;Adjust down 1 row DEC DI DEC DI ;Adjust left 1 column CMP ES:[DI],BH ;Space in column to left 1 row up? POP DI ;Restore screen pointer JNZ short TRYRHT ;No OR BL,00010000B ;Set "offset left" flag MOV ES:[DI-2],AX ;Store new character JMP short CLRCURTRYRHT: CMP DL,byte ptr[BP+ROWCNT] ;Last column? JZ short DRPCHR ;Yes CMP ES:[DI+2],BH ;Space in column to right? JNZ short DRPCHR ;No PUSH DI ;Save screen pointer SUB DI,[BP+COLCT2] ;Adjust down 1 row INC DI INC DI ;Adjust left 1 column CMP ES:[DI],BH ;Space in column to right 1 row up? POP DI ;Restore screen pointer JNZ short DRPCHR ;No OR BL,00001000B ;Set "offset right" flag MOV ES:[DI+2],AX ;Store new characterCLRCUR: MOV ES:[DI],BH ;Store space at current location JMP short NEWSPCDRPCHR: CALL RNDCHR ;Get random character MOV AH,FALATR ;Falling character color CALL RNDATR ;Invert "intense" bit if rand mod 32=0 PUSH DI ADD DI,[BP+COLCT2] ;Adjust to next row MOV ES:[DI],AX ;Store new character POP DI INC byte ptr[SI] ;Adjust rowNEWSPC: TEST BL,01000000B ;Space? JNZ short ADJSPC ;YesTSTDON: TEST BL,00100000B ;Character done? JNZ short NWSPC1 ;Yes CMP byte ptr[SI],8 ;Character at least 8 rows down? JB short TSTSPC ;NoNWSPC1: CALL RANDOM ;Get random number TEST AL,NEWMSK ;Random number & mask = 0? JNZ short TSTSPC ;No MOV byte ptr[SI+SPCROW],0 ;Clear space row OR BL,01000000B ;Set "space" flag AND BL,11011111B ;Clear "character done" flag MOV DI,DX ;Column offset to DI JMP short STOSPCTSTSPC: TEST BL,01000000B ;Space? JZ short NXTCOL ;NoADJSPC: MOV AL,[SI+SPCROW] ;Get space row CMP AL,byte ptr[BP+ROWCNT] ;Past bottom row? JB short AJSPC1 ;No MOV byte ptr[SI+SPCROW],0 ;Clear space row AND BL,10111111B ;Clear "space" flag JMP short NXTCOLAJSPC1: INC byte ptr[SI+SPCROW] ;Adjust row MOVZX DI,AL ;Row to DI INC DI ;Adjust to next row IMUL DI,[BP+COLCT2] ;Calculatate row offset ADD DI,DX ;Calculate screen pointerSTOSPC: MOV ES:byte ptr[DI],' ' ;Store spaceNXTCOL: MOV [SI+COLSTA],BL ;Update column status INC SI ;Adjust column status pointer INC DX INC DX ;Adjust column offset DEC CX ;More columns? JNZ DOCOLM ;Yes CALL GETTIK ;Get system tick count XCHG AX,BX ;Tick count to BXDLYTIK: CALL GETTIK ;Get system tick count SUB AX,BX ;Calculate elapsed tick count CMP AX,3 ;Time elapsed? JB short DLYTIK ;No XOR CX,CX XOR DX,DX MOV AX,11 INT 33H ;Get mouse motion counters TEST CX,CX ;Horizontal count changed? JNZ short EXIT ;Yes TEST DX,DX ;Vertical count changed? JNZ short EXIT ;Yes MOV AH,1 INT 16H ;Key typed? JZ UPDSCR ;No XOR AH,AH INT 16H ;Get keyEXIT: CMP [BP+VESMOD],0 ;VESA mode set? JZ short NOVESM ;No MOV AL,[BP+VIDMOD] ;Get entry text mode XOR AH,AH INT 10H ;Set entry text modeNOVESM: CALL RESSCR ;Restore user's screen MOV DI,[BP+CURLOC] ;Get original cursor offset CALL BIOCUR ;Set cursorTRMNAT: MOV AH,4CH INT 21HFNDMOD: PUSH SI ;Save supported mode list pointerFNMODZ: LODSW ;Get a mode CMP AX,BX ;Requested mode? JZ short FMODOK ;Yes CMP AX,-1 ;EOB? JNZ SHORT FNMODZ ;No OR AL,1 ;"Not found" (NZ)FMODOK: POP SI ;Restore supported mode list pointer RETRNDATR: PUSH AX ;Save character & attribute CALL RANDOM ;Get random number TEST AL,00011111B ;Mod 32 = 0? POP AX ;Restore character & attribute JNZ short RATRET ;No XOR AH,00001000B ;Invert "intense" bitRATRET: RETRNDCHR: CALL RANDOM ;Get random number CMP AL,' ' ;Space? JZ short RNDCHR ;Yes CMP AL,0FFH ;Blank? JZ short RNDCHR ;Yes CMP AL,0BH ;Weirdo 1st column character? JB short RNDCHR ;Yes CMP AL,0B0H ;Possible line or box character? JB short RCHRET ;No CMP AL,0B3H ;Line or box character? JB short RNDCHR ;Yes CMP AL,0DBH ;Possible line or box character? JB short RCHRET ;No CMP AL,0DFH ;Line or box character? JBE short RNDCHR ;YesRCHRET: RETRANDOM: MOV EAX,[BP+SEED] ;Get random seed SHL EAX,7 ;Shift left 7 ADD EAX,[BP+SEED] ;Add old seed ADD EAX,361962E9H ;Add random factor MOV [BP+SEED],EAX ;Update random seed ROL EAX,16 ;Return most random half in AX RETRNDMIZ: MOV AH,2AH INT 21H ;Get date PUSH CX PUSH DX ;Save date MOV AH,2CH INT 21H ;Get time POP AX XOR CX,AX POP AX XOR DX,AX ;Create random seed MOV word ptr[BP+SEED+2],CX MOV word ptr[BP+SEED],DX ;Store random seed RETGETTIK: PUSH DS PUSH 0 POP DS ;RAM base segment to DS MOV AX,DS:word ptr[46CH] ;Get system tick count POP DS RETSAVSCR: PUSH ES POP DS ;Screen segment to DS PUSH CS POP ES ;Code segment to ES XOR SI,SI ;Row 0, col 0 MOV DI,offset SCRBUF ;Point to screen save buffer CALL MOVSCR ;Copy screen to save buffer PUSH DS POP ES ;Screen segment to ES PUSH CS POP DS ;Code segment to DS RETRESSCR: MOV SI,offset SCRBUF ;Point to screen save buffer XOR DI,DI ;Row 0, col 0MOVSCR: MOV CX,80*25 REP MOVSW ;Copy saved screen to screen RET;Move cursor off screenCUROFF: MOV DI,60*264+0*2 ;Row 60, column 0 (off screen);set cursor to DISETCUR: PUSH AX PUSH DX MOV AL,0FH ;Cursor address low register index MOV DX,3D4H ;Point to CRTC address register OUT DX,AL ;Select cursor address low register INC DX ;Adjust to CRTC data register MOV AX,DI ;Screen address to AX SHR AX,1 ;FORM BYTE ADDRESS OUT DX,AL ;Latch low cursor address to CRTC DEC DX MOV AL,0EH ;Cursor address high register index OUT DX,AL ;Select cursor address low register INC DX ;ADJUST TO CRTC data register MOV AL,AH ;MS screen address to AL OUT DX,AL ;Latch low cursor address to CRTC POP DX POP AX RETGETCUR: PUSH DX MOV AL,0EH ;Cursor address high register index MOV DX,3D4H ;Point to CRTC address register OUT DX,AL ;Select cursor address high register INC DX ;Adjust to CRTC data register IN AL,DX ;Get high cursor address from CRTC MOV AH,AL ;High cursor address to AH DEC DX ;Adjust to CRTC address register MOV AL,0FH ;Cursor address low register index OUT DX,AL ;Select cursor address low register INC DX ;Adjust to CRTC data register IN AL,DX ;Get low cursor address from CRTC ADD AX,AX ;Form word address POP DX RETBIOCUR: XCHG AX,DI ;Screen pointer to AX SHR AX,1 ;Form column MOV CH,80 DIV CH ;Calculate row & column XCHG AL,AH ;Row to AH, column to AL XCHG AX,DX ;Row to DH, column to DL MOV AH,2 JMP short VIDBIOCONOUT: MOV AH,14VIDBIO: PUSH BX XOR BH,BH INT 10H ;Send character to console POP BX RETVARBAS VARBLE <> ;VariablesSCRBUF: END START ps: not my code. \\\\||//// (@@) ASHLEY4. |
|||
22 Sep 2004, 21:21 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.