?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1.         DEVICE ZXSPECTRUM128
  2.  
  3.         include "../../_sdk/sys_h.asm"
  4.         define G9K_DISABLE_DIRECT_EXPORT
  5.         include "g9klib/g9klib.inc"
  6.         include "g9klib/macros.inc"
  7.  
  8.         org PROGSTART
  9.  
  10. mainbegin
  11.         ld sp,0
  12.         OS_HIDEFROMPARENT
  13.         ld e,6 ;textmode
  14.         OS_SETGFX
  15.         ld e,7
  16.         OS_CLS
  17.  
  18. ;detect V9990
  19.         ld hl,detectstr
  20.         call print_hl
  21.         call G9k.Detect
  22.         ld hl,failedstr
  23.         jr nz,.printandexit
  24.         ld hl,okstr
  25.         call print_hl
  26.  
  27. ;reset chip
  28.         CALL G9k.Reset
  29.  
  30. ;test RAM
  31.         ld hl,ramteststr
  32.         call print_hl
  33.         call testcontrolreg
  34.         call testram
  35.         ld hl,failedstr
  36.         jr nz,.printandexit
  37.         ld hl,okstr
  38.         call print_hl
  39.  
  40. ;test control register
  41.         ld hl,testcontrolregstr
  42.         call print_hl
  43.         call testcontrolreg
  44.         ld hl,failedstr
  45.         jr nz,.printandexit
  46.         ld hl,okstr
  47.         call print_hl
  48.  
  49. ;show graphics test
  50.         ld hl,g9kteststr
  51.         call print_hl
  52.         call UseG9k
  53.         ld hl,failedstr
  54.         jr nz,.printandexit
  55.         ld hl,okstr
  56.  
  57. .printandexit
  58.         call print_hl
  59.         ld hl,pressanykeystr
  60.         call print_hl
  61.         YIELDGETKEYLOOP
  62.  
  63.         QUIT
  64.  
  65. testcontrolreg
  66.         xor a
  67.         out (ZX_EVA_CTRL),a
  68.  
  69.         in a,(ZX_EVA_CTRL)
  70.         and 0x0c
  71.         ret nz
  72.  
  73.         ld a,0x0c
  74.         out (ZX_EVA_CTRL),a
  75.  
  76.         in a,(ZX_EVA_CTRL)
  77.         and 0x0c
  78.         cp 0x0c
  79.         ret
  80.  
  81. testram
  82.         ld de,0x0800
  83.         ld hl,0x0000
  84.         push de
  85.         push hl
  86.         call G9k.SetVramWrite
  87. .fillloop
  88.         ld a,l
  89.         out (G9K_VRAM),a
  90.         inc l
  91.         jr nz,.fillloop
  92.         inc h
  93.         jr nz,.fillloop
  94.         inc e
  95.         dec d
  96.         jr nz,.fillloop
  97.  
  98.         pop hl
  99.         pop de
  100.         call G9k.SetVramRead
  101. .checkloop
  102.         in a,(G9K_VRAM)
  103.         cp l
  104.         ret nz
  105.         inc l
  106.         jr nz,.checkloop
  107.         inc h
  108.         jr nz,.checkloop
  109.         inc e
  110.         dec d
  111.         jr nz,.checkloop
  112.         ret
  113.  
  114. UseG9k:
  115.         LD      A,G9K_MODE_B3
  116.         LD      BC,G9K_SCR0_16BIT*256 + G9K_SCR0_XIM512
  117.         LD      DE,256 * 1 + 0
  118.         CALL    G9k.SetScreenMode
  119.  
  120.         ; Set default blitter settings
  121.         G9kWriteReg G9K_ARG,0
  122.         G9kWriteReg G9K_LOP,G9K_LOP_WCSC
  123.         LD      HL,#FFFF
  124.         CALL    G9k.SetCmdWriteMask
  125.            
  126.         ; Clear screen
  127.         LD      HL,BOX_SETTINGS
  128.         LD      DE,0x0ff0
  129.         CALL    G9k.DrawFilledBox  
  130.        
  131.         ; Wait for G9kDrawFilledBox to finish
  132.         G9kCmdWait
  133.  
  134.         ; Load vff file, if command line is empty ANTIQUE.VFF is loaded
  135.         LD      HL,DATA_BUFFER       
  136.         LD      DE,FONT_NAME0
  137.              
  138.         ; load font file
  139.         CALL    LoadFonts
  140.         RET     NZ              ; Return if error loading font
  141.  
  142.         LD      IX,font0
  143.         CALL    G9k.SetFont      ; Set font
  144.  
  145.         CALL    LoadPicture
  146.         ret nz
  147.        
  148.         CALL    G9k.DisplayEnable
  149.         LD      HL,7 * G9K_RED + 0 * G9K_GREEN + 0 * G9K_BLUE
  150.         CALL    G9k.SetCmdWriteMask
  151.         LD      DE,7 * G9K_RED + 0 * G9K_GREEN + 0* G9K_BLUE
  152.         LD      HL,BOX_SETTINGS2
  153.         CALL    G9k.DrawFilledBox
  154.         ; Wait for G9k.DrawFilledBox to finish
  155.         G9kCmdWait
  156.                
  157.         LD      HL,#FFFF
  158.         CALL    G9k.SetCmdWriteMask
  159.                
  160.         LD      HL,0 * G9K_RED + 0 * G9K_GREEN + 0 * G9K_BLUE
  161.         CALL    G9k.SetCmdBackColor
  162.         LD      HL,31 * G9K_RED + 31 * G9K_GREEN + 31 * G9K_BLUE
  163.         CALL    G9k.SetCmdColor
  164.         G9kWriteReg G9K_LOP,G9K_LOP_WCSC+G9K_LOP_TP
  165.         LD      IX,150
  166.         LD      IY,50
  167.         LD      DE,WELCOME_TXT
  168.         CALL    G9k.PrintString
  169.         G9kCmdWait
  170.  
  171.         ; Print loaded font
  172.         LD      IX,110
  173.         LD      IY,50
  174.         LD      BC,(font1.height)
  175.         ADD     IY,BC
  176.  
  177.         LD      DE,FONT_NAME0
  178.         CALL    G9k.PrintString
  179.  
  180.         LD      IX,font1
  181.         CALL    G9k.SetFont      ; Set font
  182.                
  183.         LD      DE,FONT_NAME1
  184.         LD      IX,110
  185.         LD      IY,100
  186.         CALL    G9k.PrintString
  187.  
  188.         LD      IX,font2
  189.         CALL    G9k.SetFont      ; Set font
  190.  
  191.         LD      DE,.fontInRam  
  192.         LD      IX,110
  193.         LD      IY,140
  194.         CALL    G9k.PrintString
  195.  
  196.         RET
  197.  
  198. .fontInRam      DB      "Font data in ram",0            
  199.                
  200. LoadFonts:
  201. ; Input DE=pointer to file name
  202.  
  203.         LD      IX,font0
  204.         XOR     A,A     ; Font in vram
  205.         CALL    G9k.OpenVff
  206.         RET     NZ      ; Return if error loading font
  207.        
  208.         LD      IY,FONT_OFFSET_TABLE
  209.         LD      IX,font0
  210.         LD      HL,DATA_BUFFER
  211.         LD      BC,0
  212.         CALL    G9k.LoadFont
  213.         RET     NZ      ; Return if error loading font
  214.        
  215.         LD      IX,font0
  216.         CALL    G9k.Close
  217.        
  218.         LD      DE,FONT_NAME1
  219.         LD      IX,font1
  220.         XOR     A,A     ; Font in vram
  221.         CALL    G9k.OpenVff
  222.         RET     NZ      ; Return if error loading font
  223.              
  224.         LD      BC,(font0.dataSize)              
  225.         LD      IY,FONT_OFFSET_TABLE ; Point to same offset table as font0
  226.         LD      IX,font1
  227.         LD      HL,DATA_BUFFER
  228.         CALL    G9k.LoadFont
  229.         RET     NZ      ; Return if error loading font
  230.        
  231.         LD      IX,font1
  232.         CALL    G9k.Close
  233.  
  234.         LD      DE,FONT_NAME2
  235.         LD      IX,font2
  236.         LD      A,1     ; Font in ram
  237.         CALL    G9k.OpenVff
  238.         RET     NZ      ; Return if error loading font
  239.                                  
  240.         LD      IY,FONT_OFFSET_TABLE2
  241.         LD      IX,font2
  242.         LD      HL,FONT_DATA2
  243.         CALL    G9k.LoadFont
  244.         RET     NZ      ; Return if error loading font
  245.                
  246.         LD      IX,font2
  247.         call    G9k.Close
  248.  
  249.         xor a
  250.         ret
  251.                
  252. LoadPicture:              
  253. ; Open a G9B file
  254.         LD      DE,G9B_FILE
  255.         LD      HL,g9bObject
  256.         CALL    G9k.OpenG9B
  257.         ret nz
  258.                              
  259.         LD      IX,g9bObject   ; Pointer to G9B object
  260.         LD      DE,DATA_BUFFER ; Pointer to buffer
  261.         LD      BC,30000       ; Buffer size
  262.         LD      HL,0           ; X
  263.         LD      IY,0           ; Y
  264.         LD      A,0            ; Palette pointer
  265.         CALL    G9k.ReadG9B
  266.        
  267.         LD      IX,g9bObject
  268.         call    G9k.Close
  269.  
  270.         xor a
  271.         ret
  272.  
  273. BOX_SETTINGS
  274.         DW      0,0
  275.         DW      512,212
  276. BOX_SETTINGS2                  
  277.         DW      100,50
  278.         DW      312,100
  279.  
  280. WELCOME_TXT       DB    "Gfx9000 Library v0.70",0
  281. FONT_NAME0        DB    "ANTIQUE.VFF",0
  282. FONT_NAME1        DB    "COMPUTER.VFF",0
  283. FONT_NAME2        DB    "CP111.VFF",0
  284. G9B_FILE          DB    "LAKE.G9B",0
  285.  
  286.         include "file.asm"
  287.         include "g9klib/g9klib.asm"
  288.         include "g9klib/string.asm"
  289.         include "g9klib/bitbuster.asm" 
  290.         include "g9klib/math.asm"
  291.  
  292. print_hl
  293.         ld a,(hl)
  294.         or a
  295.         ret z
  296.         push hl
  297.         PRCHAR
  298.         pop hl
  299.         inc hl
  300.         jp print_hl
  301.  
  302. detectstr
  303.         db "Detecting V9990...",0
  304. g9kteststr
  305.         db "Showing G9k Test...",0
  306. testcontrolregstr
  307.         db "Testing Eva Control Register...",0
  308. ramteststr
  309.         db "Testing RAM...",0
  310. okstr
  311.         db "OK!\r\n",0
  312. failedstr
  313.         db "Failed!\r\n",0
  314. pressanykeystr
  315.         db "Press any key...\r\n",0
  316.  
  317. mainend
  318.  
  319. g9bObject         G9B_OBJECT
  320. font0             VFF_OBJECT    ; Font data in vram
  321. font1             VFF_OBJECT    ; Font data in vram
  322. font2             VFF_OBJECT    ; Font data in ram
  323.  
  324. FONT_OFFSET_TABLE  DS   512,0
  325. FONT_OFFSET_TABLE2 DS   512,0
  326. FONT_DATA2         DS   5000,0
  327.  
  328. DATA_BUFFER ; Load routines need a buffer. This is declared here
  329.  
  330.         savebin "testV9990.com",mainbegin,mainend-mainbegin
  331.