1000 *SAVE#D:DEGASVUF.M65 1010 *ASM,#-,#D:DEGASVUF.COM 1020 * Degas *FULL* View, by Mat*Rat 1030 * 1040 * This program will load a degas 1050 * high resolution, .PI3 format 1060 * picture file and display 1/4 1070 * of it on 4 different pages 1080 * of 130XE (or compatible upgrade 1090 * upgrade XL), in Graphics mode 8. 1100 * The software will then FLIP through 1110 * them as fast as possible. Other 1120 * keyboard control options are 1130 * as follows: 1140 * 1150 * -- Key commands -- 1160 * 1 - Display 1/4 of graphic, 1st page 1170 * 2 - second page 1180 * 3 - third page 1190 * 4 - fourth page 1200 * F - full display speed, not real useful 1210 * H - show half image, alternate screens 1 & 3, 30 Hertz 1220 * S - show half image, alternate screens 2 & 4, 30 Hertz 1230 * N - Normal display, show all 4 screens, 15 hertz 1240 * SPACE - Invert display, show at normal speed 1250 * screen will stay inverted, until inverted again 1260 * RETURN - Exit to main menu for another picture selection 1270 * ESCAPE - Exit program 1280 * 1290 * At filename input prompt, press ESC twice, then return 1300 * to exit from there 1310 * 1320 * >>>BEWARE<<< Don't expect to run 1330 * this with SpartaDOS X Cartridge. 1340 * SDX likes all those RAM banks. 1350 * Go mucking about with them and 1360 * you are going to CRASH dude! 1370 * Important addresses for 1380 * loader program: 1390 ESCAPE = 27 1400 SCREEN = $E0 1410 * Byte splitting registers 1420 SHIFT1 = $E2 1430 SHIFT2 = $E3 1440 SHIFT3 = $E4 1450 SHIFT4 = $E5 1460 SAVEX = $E6 1470 BANKSCR = $4000 ;16K IS ADDR 1480 BANKSCR1 = $5000 1490 SCAN1 = 99 1500 SCAN2 = 99 1510 * Page bank select values 1520 PAGE1 = 193 1530 PAGE2 = 193+4 1540 PAGE3 = 193+8 1550 PAGE4 = 193+12 1560 MAIN = 241 1570 * Bank select register 1580 BANKSEL = 54017 1590 BLANK4 = 48 1600 BLANK5 = 64 1610 $3200 1620 LINECOUNT .BYTE 0 1630 EXFLG .BYTE 0 1640 .OPT OBJ 1650 * Mat*Rat's customized system equates 1660 .INCLUDE #D:SYSEQU.M65 1670 * Mac/65's IO Macros library 1680 .INCLUDE #D:IOMAC.LIB 1690 * Mat*Rat's Graphics routine 1700 .INCLUDE #D:GRAPHICS.M65 1710 * 2 line graphic buffer 1720 BUF160 160 1730 * Custom display list work area 1740 DISPLAY .BYTE 112,48,79 1750 .WORD BANKSCR 1760 DLA SCAN1 ; 15'S GO HERE 1770 .BYTE 79 ; SKIP 4K BOUNDARY 1780 .WORD BANKSCR1 1790 DLB SCAN2 ; ANOTHER 104 MODE 8 LINES 1800 .BYTE 65 1810 .WORD DISPLAY 1820 .BYTE 0,0,0,0 1830 * Working filename for parsing 1840 FILEN .BYTE "D1:FILENAME.EXT",155,0 1850 * Default directory spec 1860 FILSPEC .BYTE "D1:*.PI3",155,0 1870 * Initialize custom, 200 line 1880 * graphics mode 8 display 1890 * list for starters 1900 INIZ LDX #0 ; Setup display list 1910 LDA #15 1920 INIZ1 STA DLA,X 1930 INX 1940 CPX #SCAN1 1950 BNE INIZ1 1960 LDX #0 1970 INIZ2 STA DLB,X 1980 INX 1990 CPX #SCAN2 2000 BNE INIZ2 2010 * Clear screen, show title 2020 * and Start DEGAS VIEW program 2030 START 2040 GRAPHICS 0 2050 LDA #0 2060 STA 710 2070 * Get drive number first 2080 * or accept default displayed 2090 * by pressing return only 2100 CLOSE 1 2110 PRINT 0," Degas View, By Mat*Rat, (c) Analog " 2120 PRINT 0,FILSPEC 2130 PRINT 0,"[RETURN] = Keep default shown above." 2140 PRINT 0,"Drive # Degas .PI3 files are on ?" 2150 INPUT 0,FILENAME,2 2160 LDA FILENAME 2170 CMP #155 2180 BEQ NONEWDR 2190 STA FILSPEC+1 2200 * Open a directory listing 2210 * and display it 2220 NONEWDR OPEN 1,6,0,FILSPEC 2230 TYA 2240 BMI NOFILE 2250 NEXTFILE INPUT 1,FILENAME 2260 TYA 2270 BMI NOFILE 2280 PRINT 0,FILENAME 2290 JMP NEXTFILE 2300 * Request filename to view 2310 * [RETURN] only restarts, allowing 2320 * the user to change drive spec 2330 * ESCAPE will exit the program to DOS 2340 * Or type filename (no drive or ext reqd) to load 2350 NOFILE 2360 CLOSE 1 2370 PRINT 0,"Graphics file to load ?" 2380 PRINT 0,"[RETURN] = Restart, new drive" 2390 PRINT 0,"Double [ESC] and [RETURN] exits." 2400 INPUT 0,FILENAME,128 2410 CLOSE 1 2420 LDA FILENAME 2430 CMP #ESCAPE 2440 BEQ ESCEXIT 2450 CMP #155 2460 BNE GETFILE 2470 JMP START 2480 ESCEXIT GRAPHICS 0 2490 PRINT 0,"Degas View by Mat*Rat" 2500 RTS 2510 * Parse the filename 2520 * If no drive letter or number 2530 * prefixed, insert those 2540 * If no extender, paste on .PI3 2550 GETFILE LDA FILENAME 2560 LDX #0 2570 LDY #0 ; EXTENDER FOUND FLAG 2580 STY EXFLG 2590 CMP #': 2600 BEQ GETF1 2610 LDA FILENAME+1 2620 CMP #': 2630 BEQ GETF1 2640 LDA #'D 2650 STA FILEN 2660 LDA FILSPEC+1 2670 STA FILEN+1 2680 LDA #': 2690 STA FILEN+2 2700 LDY #3 2710 * If a '.' is in the filename 2720 * don't mess with the extender 2730 GETF1 LDA FILENAME,X 2740 STA FILEN,Y 2750 INX 2760 INY 2770 CMP #155 2780 BEQ GETF2 2790 CMP #'. 2800 BNE GETF1 2810 INC EXFLG 2820 JMP GETF1 2830 GETF2 LDA EXFLG 2840 BNE GETF3 2850 DEY 2860 LDA #'. 2870 STA FILEN,Y 2880 INY 2890 LDA #'P 2900 STA FILEN,Y 2910 INY 2920 LDA #'I 2930 STA FILEN,Y 2940 INY 2950 LDA #'3 2960 STA FILEN,Y 2970 INY 2980 LDA #155 2990 STA FILEN,Y 3000 GETF3 PRINT 0,FILEN 3010 OPEN 1,4,0,FILEN 3020 TYA 3030 BPL LOADIT 3040 * Bad filename or drive? 3050 * Restart the program 3060 PRINT 0,"File error, press RETURN" 3070 LDA #255 3080 HOLD CMP CH 3090 BEQ HOLD 3100 STA CH 3110 JMP START 3120 LOADIT 3130 * Let OS setup the GRAPHICS 24 3140 * originally, to get all system 3150 * variables set properly 3160 * Then point to custom display 3170 * list and memory. 3180 GRAPHICS 24 3190 LDA # DISPLAY 3210 LDY JIFFY 3220 LOADIT1 CPY JIFFY 3230 BEQ LOADIT1 3240 STA 560 3250 STX 561 3260 LDA # BANKSCR 3290 STA SAVMSC+1 3300 LDA #SCAN1+SCAN2+2 3310 STA LINECOUNT 3320 * Forget the 34 byte Degas header 3330 BGET 1,BUF160,34 ; Get and forget header 3340 TYA 3350 BPL CNTNU 3360 CLOSE 1 3370 GRAPHICS 0 3380 PRINT 0,"LOAD ERROR" 3390 RTS 3400 * Setup screen RAM pointers 3410 CNTNU 3420 LDA SAVMSC 3430 STA SCREEN 3440 LDA SAVMSC+1 3450 STA SCREEN+1 3460 LDA #10 3470 STA 710 3480 LDA #0 3490 STA 709 3500 LDA #4 3510 STA 712 3520 * Get next 2 screen lines of picture data 3530 GLINE BGET 1,BUF160,160 ; Read a line 3540 TYA 3550 BPL GLINE2 3560 GLINE1 LDX #MAIN 3570 STX BANKSEL 3580 GRAPHICS 0 3590 CLOSE 1 3600 PRINT 0,"File input error" 3610 RTS 3620 GLINE2 LDX #0 ; Buffer index 3630 * SHIFT1 will hold even pixels for even lines 3640 * SHIFT2 will hold odd pixels for even lines 3650 GLINE3 LDA BUF160,X 3660 LDY #4 3670 CLC 3680 GLINE4 ROL A 3690 ROL SHIFT1 3700 ROL A 3710 ROL SHIFT2 3720 DEY 3730 BNE GLINE4 3740 CLC 3750 LDY #4 3760 * SHIFT3 will hold even pixels for odd lines 3770 * SHIFT4 will hold odd pixels for odd lines 3780 LDA BUF160+80,X 3790 GLINE4A ROL A 3800 ROL SHIFT3 3810 ROL A 3820 ROL SHIFT4 3830 DEY 3840 BNE GLINE4A 3850 INX 3860 LDA BUF160,X 3870 LDY #4 3880 CLC 3890 GLINE5 ROL A 3900 ROL SHIFT1 3910 ROL A 3920 ROL SHIFT2 3930 DEY 3940 BNE GLINE5 3950 LDY #4 3960 CLC 3970 LDA BUF160+80,X 3980 GLINE5A ASL A 3990 ROL SHIFT3 4000 ASL A 4010 ROL SHIFT4 4020 DEY 4030 BNE GLINE5A 4040 STX SAVEX 4050 LDX #PAGE1 4060 * Stuff pixel data in PAGE1 bank 4070 * and main bank. Use PAGE1,2,3,4 4080 * for computational convenience 4090 * Shove copy of PAGE1 in MAIN 4100 * so display doesn't flash garbage 4110 * during keyboard inputs. 4120 * 4130 * Stuff appropriate shift bytes 4140 * into proper pages, as enabled. 4150 STX BANKSEL 4160 LDA SHIFT1 4170 STA (SCREEN),Y 4180 LDX #MAIN 4190 STX BANKSEL 4200 STA (SCREEN),Y 4210 LDX #PAGE2 4220 STX BANKSEL 4230 LDA SHIFT2 4240 STA (SCREEN),Y 4250 LDX #PAGE3 4260 STX BANKSEL 4270 LDA SHIFT3 4280 STA (SCREEN),Y 4290 LDX #PAGE4 4300 STX BANKSEL 4310 LDA SHIFT4 4320 STA (SCREEN),Y 4330 INC SCREEN 4340 BNE CHKDN 4350 INC SCREEN+1 4360 * Restore buffer index and check 4370 * if done reading picture file. 4380 CHKDN LDX SAVEX 4390 INX 4400 CPX #80 4410 BEQ UPDLINE 4420 JMP GLINE3 4430 UPDLINE 4440 DEC LINECOUNT 4450 BEQ SHOIT0 4460 LDA LINECOUNT 4470 CMP #100 4480 BNE JMGL 4490 LDA # BANKSCR1 4520 STA SCREEN+1 4530 JMGL 4540 JMP GLINE 4550 * Display routine 4560 * Enable respective banks 4570 * Stick BLANK4 lines command in 4580 * display list for even line pages 4590 * and BLANK5 for odd line pages 4600 * This is done to minimixe vertical 4610 * jitter during page flipping. 4620 * Horizontal jitter is not eliminated, 4630 * however, as it would require some 4640 * extra fancy bit shifting at load 4650 * time. Not fun. 4660 * 4670 SHOIT0 CLOSE 1 4680 SHOIT LDX #PAGE1 4690 LDY #BLANK4 4700 SHOIT1A LDA JIFFY 4710 SHOIT1 CMP JIFFY 4720 BEQ SHOIT1 4730 STX BANKSEL 4740 STY DISPLAY+1 4750 INX 4760 INX 4770 INX 4780 INX 4790 CPX #PAGE3 4800 BNE SHOIT2 4810 LDY #BLANK5 4820 SHOIT2 LDA CH 4830 CMP #255 4840 BNE SHOIT3 4850 CPX #PAGE4+4 4860 BEQ SHOIT 4870 BNE SHOIT1A 4880 * Always re-enable MAIN bank 4890 * before exiting any display loop! 4900 SHOIT3 LDX #MAIN 4910 STX BANKSEL 4920 * Process key command 4930 * ESCAPE - Exit to dos 4940 * 1 - Display static screen, page 1 only 4950 * 2 - Display page 2 4960 * 3 - Display page 3 4970 * 4 - Display page 4 4980 * H - Show half of image, flip screens 4990 * 1 & 3 at 30 hertz 5000 * S - Show half of image, flip screens 5010 * 2 & 4 at 30 hertz 5020 * F - Fastest display possible, a bit 5030 * useless, but easy enuf to throw in 5040 * N - Normal display (SHOIT above) 5050 * SPACE - Invert displays, swap color registers, simple 5060 * 5070 * Any other key loops back to START 5080 HOLDIT CLOSE 4 5090 OPEN 4,4,0,"K:" 5100 TYA 5110 BPL HOLDNOW 5120 CLOSE 4 5130 JMP START 5140 HOLDNOW BGET 4,FILENAME,1 5150 LDA FILENAME 5160 * SPACE - Invert display? 5170 CMP #32 ; SPACE? 5180 BNE CKSCL 5190 JMP INVERT 5200 * (H)alf display, 1&3 ? 5210 CKSCL CMP #'H 5220 BNE CKSNRM 5230 JMP SHOHALF 5240 * (N)ormal display, 4 pages? 5250 CKSNRM CMP #'N 5260 BNE CKSFAST 5270 JMP SHOIT 5280 * (F)astest possible flipping? 5290 CKSFAST CMP #'F 5300 BNE CKSCS 5310 JMP FASTEST 5320 CKSCS 5330 * (S)how half, pages 2&4? 5340 CMP #'S 5350 BNE CK1 5360 JMP SHOSECHAF 5370 * (1)-show screen 1 only? 5380 CK1 CMP #'1 5390 BNE CK2 5400 LDX #PAGE1 5410 BNE SVPG 5420 * (2)-show screen 2 only? 5430 CK2 CMP #'2 5440 BNE CK3 5450 LDX #PAGE2 5460 BNE SVPG 5470 * (3)-show screen 3 only? 5480 CK3 CMP #'3 5490 BNE CK4 5500 LDX #PAGE3 5510 BNE SVPG 5520 * (4)-show screen 4 only? 5530 CK4 CMP #'4 5540 BNE CKESC 5550 LDX #PAGE4 5560 SVPG STX BANKSEL 5570 LDX #255 5580 SVPG1 CPX CH 5590 BEQ SVPG1 5600 LDX #MAIN 5610 STX BANKSEL 5620 JMP HOLDNOW 5630 * (ESCAPE) from the program? 5640 CKESC CMP #ESCAPE 5650 BNE RESTART 5660 CLOSE 4 5670 PRINT 0,"Degas View by Mat*Rat, (c) Analog" 5680 RTS 5690 RESTART CLOSE 4 5700 JMP START 5710 * INVERT routine - swap color 5720 * registers 709 & 710 5730 INVERT LDA 710 5740 PHA 5750 LDA 709 5760 STA 710 5770 PLA 5780 STA 709 5790 JMP SHOIT 5800 * Show (H)alf, pages ! & 3 5810 SHOHALF LDX #PAGE1 5820 LDA JIFFY 5830 SHOH1 CMP JIFFY 5840 BEQ SHOH1 5850 STX BANKSEL 5860 LDX #PAGE3 5870 LDA JIFFY 5880 SHOH2 CMP JIFFY 5890 BEQ SHOH2 5900 STX BANKSEL 5910 LDX CH 5920 CPX #255 5930 BEQ SHOHALF 5940 LDX #MAIN 5950 STX BANKSEL 5960 JMP HOLDNOW 5970 * (S)how half, pages 2 & 4 5980 SHOSECHAF LDX #PAGE2 5990 LDA JIFFY 6000 SHOS1 CMP JIFFY 6010 BEQ SHOS1 6020 STX BANKSEL 6030 LDX #PAGE4 6040 LDA JIFFY 6050 SHOS2 CMP JIFFY 6060 BEQ SHOS2 6070 STX BANKSEL 6080 LDX CH 6090 CPX #255 6100 BEQ SHOSECHAF 6110 LDX #MAIN 6120 STX BANKSEL 6130 JMP HOLDNOW 6140 * Show all screens (F)astest 6150 FASTEST LDA #255 6160 FASTEST1 LDX #PAGE1 6170 STX BANKSEL 6180 LDX #PAGE2 6190 STX BANKSEL 6200 LDX #PAGE3 6210 STX BANKSEL 6220 LDX #PAGE4 6230 STX BANKSEL 6240 CMP CH 6250 BEQ FASTEST1 6260 LDX #MAIN 6270 STX BANKSEL 6280 JMP HOLDNOW 6290 *= $02E0 6300 .WORD INIZ