+;;=======================================================================;;\r
+;; ;;\r
+;; Scrolling Routines -- main program ;;\r
+;; ;;\r
+;; All other INC files are included here. The main routines for the ;;\r
+;; frame-by-frame execution loop are also here. Finally I tried to keep ;;\r
+;; global variables stored in this file as well. ;;\r
+;; ;;\r
+;;=======================================================================;;\r
+ dosseg\r
+ .model small\r
+ .386\r
+\r
+ .code\r
+ extrn ZTimerOn:far, ZTimerOff:far, ZTimerReport:far\r
+\r
+INCLUDE constant.inc\r
+\r
+\r
+DW_TABLE MACRO inc,num\r
+ count = 0\r
+ number = 0\r
+ WHILE (count LT num)\r
+ DW number\r
+ count = count + 1\r
+ number = number + inc\r
+ ENDM\r
+ ENDM\r
+\r
+DOSPRINT MACRO st\r
+ mov ah,9\r
+ mov dx,st\r
+ int 21h\r
+ ENDM\r
+\r
+EVEN\r
+Mult320 label WORD\r
+MultBufWidth label WORD\r
+ DW_TABLE 320,200\r
+MultVirtWidth label WORD\r
+ DW_TABLE (VIRTUAL_WIDTH/4),200\r
+\r
+INCLUDE palette.inc\r
+INCLUDE keyb.inc\r
+INCLUDE modex.inc\r
+INCLUDE page.inc\r
+INCLUDE init.inc\r
+INCLUDE map.inc\r
+;INCLUDE sprite.inc NOT FOR NOW\r
+INCLUDE scroll.inc\r
+\r
+;; Various segments that need to be filled in later...\r
+EVEN\r
+segVideo dw 0A000h ; videoram segment\r
+segText dw 0B800h ; text segment\r
+segMap dw -1 ; Map info segment\r
+segTiles dw -1 ; Tile bitmap segment\r
+segBuffer dw -1 ; Local 320x200 buffer segment\r
+segCode dw -1 ; Code segment\r
+segPSP dw -1 ; PSP segment\r
+segPalette dw -1 ; Palette segment\r
+segTextPal dw -1 ; Saved text palette\r
+\r
+EVEN\r
+bDoTransition db 0\r
+\r
+;; This routine is called for each frame.\r
+;; Right now it just scrolls, but later all sprite animation would\r
+;; occur here too.\r
+EVEN\r
+OneFrame PROC near\r
+ call Scroll ; Scrolls the screen\r
+; call AnimateSprites ; prepares sprites on drawpage\r
+ jmp FlipPage ; shows drawpage...\r
+ ; no RET necessary\r
+OneFrame ENDP\r
+\r
+;; Each frame -- call the frame motion code, then check for keyhit.\r
+EVEN\r
+MainLoop PROC NEAR\r
+next_frame: call OneFrame\r
+ JNKEY next_frame\r
+ JKEYP kESC,all_done ; ESC -> quit, always\r
+ call kprocCur\r
+ mov al,bDoTransition\r
+ cmp al,0\r
+ je next_frame\r
+transition: FLASH_OFF 16,segPalette\r
+ mov bDoTransition,0\r
+ mov ax,1\r
+ sub ax,nMap\r
+ mov nMap,ax ; Flip maps\r
+\r
+ call LoadData\r
+ call update_full ;<<<<\r
+ call OneFrame\r
+ FLASH_ON 16,segPalette\r
+ jmp next_frame\r
+all_done: ret\r
+MainLoop ENDP\r
+\r
+;; Beginning code -- Leaves text mode (saving the text screen) via\r
+;; a fade. It loads the map data and draws one\r
+;; frame before it fades on.\r
+Beginning PROC near\r
+ NEW_PAL segTextPal\r
+ PAL_SAVE segTextPal\r
+ FADE_OFF 1,segTextPal\r
+ call SaveVideo\r
+ MODEX_START ; 320x200 Mode X graphics mode\r
+ PAL_BLACK\r
+\r
+ call LoadData ; This call will change...\r
+\r
+ call update_full ;<<<<\r
+ call OneFrame\r
+ FADE_ON 1,segPalette\r
+ ret\r
+Beginning ENDP\r
+\r
+;; Ending code -- restore to text mode via a flash\r
+Ending PROC near\r
+ FLASH_OFF 8,segPalette\r
+ call RestoreVideo\r
+ FLASH_ON 8,segTextPal\r
+ ret\r
+Ending ENDP\r
+\r
+ .data\r
+\r
+ .stack 2048\r
+\r
+ END Initialize\r
+\1a
\ No newline at end of file