grf_ultms.g revision 1.8
11.8Sis; $NetBSD: grf_ultms.g,v 1.8 2003/07/16 19:58:59 is Exp $ 21.2Schopps; 31.2Schopps; ite support for A2410. 41.2Schopps 51.2Schopps; 61.2Schopps; Copyright (c) 1995 Ignatios Souvatzis. 71.2Schopps; All rights reserved. 81.2Schopps; 91.2Schopps; Redistribution and use in source and binary forms, with or without 101.2Schopps; modification, are permitted provided that the following conditions 111.2Schopps; are met: 121.2Schopps; 1. Redistributions of source code must retain the above copyright 131.2Schopps; notice, this list of conditions and the following disclaimer. 141.2Schopps; 2. Redistributions in binary form must reproduce the above copyright 151.2Schopps; notice, this list of conditions and the following disclaimer in the 161.2Schopps; documentation and/or other materials provided with the distribution. 171.2Schopps; 3. All advertising materials mentioning features or use of this software 181.2Schopps; must display the following acknowledgement: 191.3Sis; This product contains software developed by Ignatios Souvatzis 201.3Sis; for the NetBSD project. 211.2Schopps; 4. The name of the author may not be used to endorse or promote products 221.5Swiz; derived from this software without specific prior written permission 231.2Schopps; 241.2Schopps; THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 251.2Schopps; IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 261.2Schopps; OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 271.2Schopps; IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 281.2Schopps; INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 291.2Schopps; NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 301.2Schopps; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 311.2Schopps; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 321.2Schopps; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 331.2Schopps; THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 341.2Schopps 351.8Sis; This file contains the source code for grf_ultms.c. It is assembler 361.8Sis; code for the TMS34010 CPU/graphics processor, as understood by the 371.8Sis; in-tree version of Paul Mackerras' "gspa" assembler. 381.2Schopps; 391.7Sjdolecek; Use 'make grf_ultms.c' to generate the .c file. 401.2Schopps 411.2Schopps; memory map: 421.2Schopps; FF800000 .. FF9FFFFF overlay planes 431.2Schopps; FFA00000 .. FFA0FFFF ite support code 441.2Schopps; FFA10000 .. FFA1FFFF ite support, input queue 451.2Schopps; FFA20000 .. FFA2FEFF variables 461.2Schopps; FFA2FF00 .. FFA2FFFF variables, X server 471.2Schopps; FFA30000 .. FFA3FFFF font data 481.2Schopps; FFA40000 .. FFA4FFFF font data, bold 491.2Schopps; FFA50000 .. FFA5FFFF X server, input queue 501.2Schopps; FFA60000 .. FFFFC000 X server, onboard pixmaps 511.2Schopps 521.2Schopps; Start of data area 531.2Schopps .org $FFA20000 541.2Schoppsd: 551.2Schopps 561.2Schopps; 571.2Schopps; Ring buffer for getting stuff from host 581.2Schopps; Data buffer: 591.2Schoppsinbuf = $FFA10000 ; 64kbits here (8k bytes) 601.2Schopps; 611.2Schopps; Pointers: (these must be at address $FFA20000) 621.2Schoppsput: .long inbuf 631.2Schoppsget: .long inbuf 641.2Schopps 651.2Schopps; 661.2Schopps; Mode bits for communication between GSP and CPU 671.2Schopps; 681.2Schopps; GSP mode bits: set by CPU, control GSP operation 691.2SchoppsGSP_HOLD = 0 701.2SchoppsGSP_FLUSH = 1 711.2SchoppsGSP_ALT_SCRN = 2 721.2SchoppsGSP_DISP_CTRL = 3 731.2SchoppsGSP_NO_CURSOR = 4 741.2SchoppsGSP_CALL_X = 5 751.2Schoppsgsp_mode: .word 0 761.2Schopps 771.2Schopps; 781.2Schopps; Pointer to X operation routine 791.2Schoppsxproc: .long 0 801.2Schopps 811.2Schopps; We leave the next few words for future communication requirements 821.2Schopps 831.2Schopps .org d+0x100 841.2Schopps; 851.2Schopps; Other data: 861.2Schoppsmagic: .blkl 1 ; set => screen already inited 871.2SchoppsMAGIC = 0xD0D0BEAC 881.2Schopps 891.2Schoppsscreen_width: .word 1024 901.2Schoppsscreen_height: .word 768 911.2Schoppsscreen_origin: .long $FE000000 ; just a placeholder 921.2Schoppsscreen_pitch: .word 8192 ; 1024*8 931.2Schoppspixel_size: .word 8 941.2Schopps 951.2Schopps .org d+0x200 961.2Schoppsfont_adr: 971.2Schopps; 981.2Schopps; Font information is stored in the structure defined declared below. 991.2Schopps; 1001.2Schoppsbitmap_ptrs: .long $FFA30000 ; points to first bitmap 1011.2Schoppsfont_size: .long $00080008 ; Y:X bitmap size 1021.2Schoppsunder_row: .word 6 ; row # for underlines 1031.2Schoppsunder_ht: .word 1 ; thickness of underline 1041.2Schoppsfirst_char: .word 32 ; first and last char in font 1051.2Schoppslast_char: .word 255 ; 1061.2Schoppsbold_smear: .word 1 ; for making bold fonts 1071.2Schopps 1081.2Schoppsbgcolor: .long 0 ; background color 1091.2Schoppsfgcolor: .long $01010101 ; foreground color 1101.2Schopps;precomputed out of what the host gave us: 1111.2Schoppsfont_area: .word 64 ; in pixels 1121.2Schoppsfont_pitch: .word 8 1131.2Schoppsfont_lmo: .word 28 1141.2Schopps 1151.2Schopps 1161.2Schopps; Control register addresses 1171.2Schoppshesync = $c0000000 1181.2Schoppsdpyctl = $c0000080 1191.2Schoppscontrol = $c00000b0 1201.2Schoppsconvsp = $c0000130 1211.2Schoppsconvdp = $c0000140 1221.2Schoppspsize = $c0000150 1231.2Schopps 1241.2Schopps; 1251.2Schopps; Bits in control register 1261.2SchoppsT = $20 ; enable transparency 1271.2SchoppsW = $C0 ; window options 1281.2SchoppsPBH = $100 ; pixblt horiz dirn 1291.2SchoppsPBV = $200 ; pixblt vertical dirn 1301.2SchoppsPPOP = $7C00 ; pixel processing options 1311.2Schopps 1321.2Schopps; 1331.2Schopps; Bits in dpyctl register 1341.2SchoppsSRT = $800 ; do serial register transfers 1351.2Schopps 1361.2Schoppsfree_memory: .long free_memory_start 1371.2Schoppsfree_memory_start: ; allocate dynamic arrays from here 1381.2Schopps 1391.2Schopps; 1401.2Schopps; Program starts here. 1411.2Schopps .org $FFA00000 1421.2Schopps .start . 1431.2Schopps 1441.2Schopps; 1451.2Schopps; initialization 1461.2Schopps; 1471.2Schopps setf 16,0,0 ; just in case 1481.2Schopps setf 32,0,1 1491.2Schopps move $fffff000,sp 1501.2Schopps 1511.2Schopps; Set up sync, blank parameters 1521.2Schopps; done by host through interface 1531.2Schopps 1541.2Schopps; set up overlay clut: 1551.2Schopps move $0,a0 1561.2Schopps move a0,@$fe800000 1571.2Schopps move $fe800030,a1 1581.2Schopps move 128,a0 1591.2Schopps move a0,*a1 1601.2Schopps move a0,*a1 1611.2Schopps move a0,*a1 1621.2Schopps move 0,a0 1631.2Schopps move a0,*a1 1641.2Schopps move a0,*a1 1651.2Schopps move a0,*a1 1661.2Schopps move a0,*a1 1671.2Schopps move a0,*a1 1681.2Schopps move a0,*a1 1691.2Schopps move a0,*a1 1701.2Schopps move a0,*a1 1711.2Schopps move a0,*a1 1721.2Schopps 1731.2Schopps; set up overlay planes: 1741.2Schopps move 6,a0 1751.2Schopps move a0,@$fe800000 1761.2Schopps move $0b,a0 1771.2Schopps move a0,@$fe800020 1781.2Schopps 1791.2Schopps; set up global registers 1801.2Schopps move @screen_pitch,b3,0 1811.2Schopps move @screen_origin,b4,1 1821.2Schopps move @bgcolor,b8,1 1831.2Schopps lmo b3,b0 1841.2Schopps move b0,@convdp,0 1851.2Schopps move @control,a0,0 1861.2Schopps andn $7FE0,a0 ; clear PPOP, PBV, PBH, W, T fields 1871.2Schopps move a0,@control,0 1881.2Schopps move @pixel_size,a0,0 1891.2Schopps move a0,@psize,0 1901.2Schopps move @psize,a0,0 1911.2Schopps 1921.2Schopps 1931.2Schopps; clear the entire screen 1941.2Schopps move b4,b2 1951.2Schopps move 0,b9 1961.2Schopps move @screen_width,b7,1 1971.2Schopps fill l 1981.2Schopps 1991.2Schopps4: 2001.2Schopps; main stuff... 2011.2Schopps move @get,a0,1 2021.2Schopps jruc main_loop 2031.2Schoppsloop_end: 2041.2Schopps clr a4 2051.2Schopps move a4,*a0,0 2061.2Schopps addxy a1,a0 2071.2Schopps move a0,@get,1 2081.2Schoppsmain_loop: 2091.2Schopps move @gsp_mode,a1,0 2101.2Schopps btst GSP_CALL_X,a1 2111.2Schopps jreq main_loop_1 2121.2Schopps 2131.2Schopps mmtm sp,a0,a1,a2,a3 2141.2Schopps move @xproc,a4,1 2151.2Schopps call a4 2161.2Schopps mmfm sp,a0,a1,a2,a3 2171.2Schopps 2181.2Schoppsmain_loop_1: 2191.2Schopps move @put,a3,1 2201.2Schopps move *a0,a1,0 2211.2Schopps 2221.2Schopps move a1,a2 2231.2Schopps andi $FFF0,a1 2241.2Schopps jrz main_loop 2251.2Schopps 2261.2Schopps sub a0,a3 2271.2Schopps jreq main_loop 2281.2Schoppscontinue: 2291.2Schopps andi $F,a2 2301.2Schopps jrz loop_end 2311.2Schopps dec a2 2321.2Schopps jrnz testfor2 2331.2Schopps; op 1 - char 2341.2Schopps movk 6,b10 2351.2Schopps move b10,@$fe800000,0 2361.2Schopps movk 1,b10 2371.2Schopps move b10,@$fe800020,0 2381.2Schopps 2391.2Schopps move a0,b10 2401.2Schopps move *b10+,b12,0 ; dummy move (faster than addk) 2411.2Schopps move *b10+,b12,0 ; char code 2421.2Schopps move @first_char,b11,0 2431.2Schopps sub b11,b12 ; minus first char in font 2441.2Schopps move @font_size,b7,1 ;dydx - char size->pixel array dimensions 2451.2Schopps move @font_pitch,b1 2461.2Schopps move @font_lmo,b0 2471.2Schopps move b0,@convsp,0 2481.2Schopps move @font_area,b11 2491.6Saymeric 2501.2Schopps mpyu b12,b11 ; times char offset 2511.2Schopps move @font_adr,b0,1 ; font bitmaps base 2521.2Schopps add b11,b0 ; character bitmap start addr. linear 2531.2Schopps 2541.2Schopps move *b10+,b8,0 ; fg 2551.2Schopps move *b10+,b9,0 ; bg 2561.2Schopps move *b10+,b2,1 ; y:x 2571.2Schopps 2581.2Schopps move *b10+,b11,0 ; flags 2591.2Schopps move b11,a4 2601.2Schopps btst 0,a4 2611.2Schopps jreq noinv 2621.2Schopps move b8,b11 2631.2Schopps move b9,b8 2641.2Schopps move b11,b9 2651.2Schoppsnoinv: 2661.2Schopps btst 2,a4 2671.2Schopps jreq nobold 2681.2Schopps addi $10000,b0 2691.2Schoppsnobold: 2701.2Schopps move b2,a5 2711.2Schopps pixblt b,xy 2721.2Schopps move a5,b2 2731.2Schopps 2741.2Schopps btst 1,a4 2751.2Schopps jreq noul 2761.2Schopps move @under_row,b11,0 2771.2Schopps sll 16,b11 ; shift into Y half 2781.2Schopps add b11,b2 2791.2Schopps move @under_ht,b11,0 2801.2Schopps sll 16,b11 ; shift into Y half 2811.2Schopps movy b11,b7 ; and move Y half only 2821.2Schopps fill xy 2831.2Schoppsnoul: 2841.2Schopps jruc loop_end 2851.2Schoppstestfor2: 2861.2Schopps dec a2 2871.2Schopps jrnz testfor3 2881.2Schopps; op 2 - fill 2891.2Schopps move a0,b10 2901.2Schopps move *b10+,b9,0 ; dummy move 2911.2Schopps move *b10+,b9,0 ; color 2921.2Schopps move *b10+,b2,1 ; XY start address 2931.2Schopps move *b10+,b7,1 ; dydx 2941.2Schopps 2951.2Schopps move @control,b0,0 2961.2Schopps move b0,*-sp 2971.2Schopps move *b10+,b0 2981.2Schopps setf 5,0,0 2991.2Schopps move b0,@control+10 3001.2Schopps setf 16,0,0 3011.2Schopps move @control,b0,0 3021.2Schopps 3031.2Schopps fill xy 3041.2Schopps 3051.2Schopps move *sp+,b0 3061.2Schopps move b0,@control,0 3071.2Schopps jruc loop_end,l 3081.2Schopps 3091.2Schoppstestfor3: 3101.2Schopps dec a2 3111.2Schopps jrnz testfor4 3121.2Schopps; op 3 - pixblt 3131.2Schopps move a0,b10 3141.2Schopps move @convdp,@convsp,0 3151.2Schopps move *b10+,b0,0 ; dummy move 3161.2Schopps move *b10+,b0,1 ; XY src 3171.2Schopps move *b10+,b7,1 ; dxdy 3181.2Schopps move *b10+,b2,1 ; XY dst 3191.2Schopps move b3,b1 3201.2Schopps move @control,b11,0 3211.2Schopps andni PBH|PBV,b11 3221.2Schopps cmpxy b0,b2 3231.2Schopps jrc yok 3241.2Schopps ori PBV,b11 3251.2Schoppsyok: jrv xok 3261.2Schopps ori PBH,b11 3271.2Schoppsxok: move b11,@control,0 3281.2Schopps move @control,b11,0 3291.6Saymeric 3301.2Schopps pixblt xy,xy 3311.2Schopps jruc loop_end,l 3321.2Schopps 3331.2Schoppstestfor4: 3341.2Schopps dec a2 3351.2Schopps jrnz testfor5 3361.2Schopps 3371.2Schopps; op 4 - mirror the font and precompute some values. 3381.2Schopps 3391.2Schopps move @font_size,a5,0 3401.2Schopps movk 8,a6 3411.2Schopps cmp a6,a5 3421.2Schopps jrle t4b8 3431.2Schopps movi 16, a6 3441.2Schoppst4b8: move a6,@font_pitch,0 3451.2Schopps lmo a5,a6 3461.2Schopps move a6,@font_lmo,0 3471.2Schopps move @font_size+$10,a6,0 3481.2Schopps move @font_pitch,a5,0 3491.2Schopps mpyu a6,a5 3501.2Schopps move a5,@font_area,0 3511.2Schopps 3521.2Schopps move @last_char,a6,0 3531.2Schopps move @first_char,a5,0 3541.2Schopps sub a5,a6 3551.2Schopps addk 1,a6 3561.2Schopps move @font_size+$10,a5,0 3571.2Schopps mpyu a6,a5 3581.2Schopps move @font_size,a7,0 3591.2Schopps cmpi 8,a7 3601.2Schopps move $7f7f,a12 ; mask for bold smearing 3611.2Schopps jrgt t4bf ; wider than 8 pixels? 3621.2Schopps addk 1,a5 ; yes, the words are only half the # of rows 3631.2Schopps srl 1,a5 3641.2Schopps move $7fff,a12 ; mask for bold smearing changes, too 3651.2Schoppst4bf: move @font_adr,a6,1 3661.2Schopps move a6,a9 3671.2Schopps addi $10000,a9 ; start address of bold font 3681.2Schopps move @bold_smear,a10 3691.2Schopps 3701.2Schopps; fortunately, this loop fits into 3 of the 4 cache segments: 3711.2Schopps; execution time: about 32 periods per word of font. 3721.2Schopps 3731.2Schoppsmirlp: move *a6,a7 3741.2Schopps clr a8 3751.2Schopps 3761.2Schopps srl 1,a7 3771.2Schopps addc a8,a8 3781.2Schopps srl 1,a7 3791.2Schopps addc a8,a8 3801.2Schopps srl 1,a7 3811.2Schopps addc a8,a8 3821.2Schopps srl 1,a7 3831.2Schopps addc a8,a8 3841.2Schopps 3851.2Schopps srl 1,a7 3861.2Schopps addc a8,a8 3871.2Schopps srl 1,a7 3881.2Schopps addc a8,a8 3891.2Schopps srl 1,a7 3901.2Schopps addc a8,a8 3911.2Schopps srl 1,a7 3921.2Schopps addc a8,a8 3931.2Schopps 3941.2Schopps srl 1,a7 3951.2Schopps addc a8,a8 3961.2Schopps srl 1,a7 3971.2Schopps addc a8,a8 3981.2Schopps srl 1,a7 3991.2Schopps addc a8,a8 4001.2Schopps srl 1,a7 4011.2Schopps addc a8,a8 4021.2Schopps 4031.2Schopps srl 1,a7 4041.2Schopps addc a8,a8 4051.2Schopps srl 1,a7 4061.2Schopps addc a8,a8 4071.2Schopps srl 1,a7 4081.2Schopps addc a8,a8 4091.2Schopps srl 1,a7 4101.2Schopps addc a8,a8 4111.2Schopps 4121.2Schopps move a8,*a6+ 4131.2Schopps move a8,a7 4141.2Schopps move a10,a11 4151.2Schoppssmearlp: 4161.2Schopps and a12,a7 4171.2Schopps sll 1,a7 4181.2Schopps or a7,a8 4191.2Schopps dsj a11,smearlp 4201.2Schopps move a8,*a9+ 4211.2Schopps 4221.2Schopps dsj a5,mirlp 4231.2Schopps;; support odd-sized fonts. pitch must still be 8 or 16 4241.2Schopps move @font_size,a5,0 4251.2Schopps move @font_pitch,a6,0 4261.2Schopps sub a5,a6 4271.2Schopps move @font_adr,a5,1 4281.2Schopps add a5,a6 4291.2Schopps move a6,@font_adr,1 4301.2Schopps;; 4311.2Schopps jruc loop_end,l 4321.2Schopps 4331.6Saymeric 4341.2Schoppstestfor5: 4351.2Schopps dec a2 4361.2Schopps jrne testfor6 4371.2Schopps; loadclut --- load clut entry. 4381.2Schopps; 1==overlay index red green blue 4391.2Schopps; for speed reasons, the host will load the image clut directly rather 4401.6Saymeric; than through us, but its not that expensive to support both here 4411.2Schopps; just in case 4421.2Schopps move a0,a4 4431.2Schopps addk $10,a4 4441.2Schopps move $fe800030,a6 4451.2Schopps move *a4+,a5,0 4461.2Schopps jrne t5l1 4471.2Schopps subk $20,a6 4481.2Schoppst5l1: move *a4+,a5,0 4491.2Schopps move a5,@$fe800000,0 4501.2Schopps move *a4+,a5,0 4511.2Schopps move a5,*a6,0 4521.2Schopps move *a4+,a5,0 4531.2Schopps move a5,*a6,0 4541.2Schopps move *a4+,a5,0 4551.2Schopps move a5,*a6,0 4561.2Schopps jruc loop_end,l 4571.6Saymeric 4581.2Schoppstestfor6: 4591.2Schopps dec a2 4601.2Schopps jrne testfor7 4611.2Schopps 4621.2Schopps; op 6: load new framebuffer size and position for ite support. 4631.2Schopps move a0,b10 4641.2Schopps addk $10,b10 4651.2Schopps move *b10+,b7,1 4661.2Schopps move b7,@screen_width,1 4671.2Schopps move *b10+,b4,1 4681.2Schopps move b4,@screen_origin,1 4691.2Schopps move *b10+,b3,0 4701.2Schopps move b3,@screen_pitch,0 4711.2Schopps lmo b3,b0 4721.2Schopps move b0,@convdp,0 4731.2Schopps move *b10,b0,0 4741.2Schopps move b0,@psize,0 4751.2Schopps move b0,@pixel_size,0 ; this syncs the psize write, too 4761.2Schopps 4771.2Schopps jruc loop_end,l 4781.6Saymeric 4791.2Schoppstestfor7: 4801.2Schopps jruc loop_end,l 4811.2Schopps;;; 482