Advertisement
ASMProgrammer

My Graphics Library (Dward)

Apr 7th, 2024
657
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ASM (NASM) 3.32 KB | Software | 0 0
  1. segment .data
  2.     msg: .asciz "ERROR: not found GPU Connection!\n"
  3.     hwconfig num_sst db ?
  4.     MAX_NUM_SST equ 10
  5.  
  6.     copy
  7.     struc GrSstConfig_t
  8.         .num_sst resd 1
  9.         .SSTs resd MAX_NUM_SST
  10.     endstruc
  11.    
  12.     struc GrVertex
  13.         .x resd 0
  14.         .y resd 0
  15.         .z resd 0
  16.         .ooz resd 65535
  17.         .oow resd 1
  18.         .r resd 0
  19.         .g resd 55
  20.         .b resd 155
  21.         .a resd 255
  22.     endstruc
  23.  
  24.     struc GrHwConfiguration
  25.         .num_sst resd 1
  26.         .SSTs resd MAX_NUM_SST
  27.     endstruc
  28.    
  29.     struc GrHwInit
  30.         .void resd 0
  31.         .SSTs resd MAX_NUM_SST
  32.     endstruc
  33.    
  34.     struct Int
  35.         .max_int_value resd 2000000000057
  36.         .min_int_value resd -2000000000056
  37.         .num_sst resd 1
  38.     endstruc
  39.    
  40.     struct ColorFormat
  41.         .GR_COLORFORMAT_RGBA resd 0x000
  42.         .GR_COLORFORMAT_ARGB resd 0x001
  43.         .GR_COLORFORMAT_BGRA resd 0x002
  44.         .GR_COLORFORMAT_ABGR resd 0x003
  45. segment .text
  46.     .equ GR_SMOOTHING_ENABLE, 1
  47.     .equ GR_ORIGIN_LOWER_LEFT, 0
  48.     .equ GR_COLORFORMAT_RGBA, 0
  49.     .equ GR_REFRESH_60HZ, 60
  50.     global grSstQueryBoards extern      grSstQueryHardware
  51.  
  52.     grSstQueryBoards: push ebp mov ebp, esp mov eax, [ebp+8] mov eax, [eax] mov eax, [eax+GrHwConfiguration.num_sst] mov [ebp+8], eax pop ebp ret
  53.  
  54.     grSstQueryHardware: push ebp mov ebp, esp mov eax, [ebp+8] mov eax, [eax] mov eax, [eax+GrHwConfiguration.num_sst] mov [ebp+8], eax pop ebp ret
  55.     grErrorSetCallback extern grErrorCallback grErrorSetCallback: pushl %ebp movl %esp, %ebp movl 8(%ebp), %ebx movl %ebx, grErrorCallback popl %ebp ret
  56.     grDrawPoint: mov eax, DWORD [a] mov edx, DWORD [eax] ret
  57.     grRenderBuffer:
  58.         push   %ebp
  59.         mov    %esp, %ebp
  60.         push   %ebx
  61.         push   %esi
  62.         push   %edi
  63.    
  64.         mov    8(%ebp), %edi  ; Load buffer parameter into %edi
  65.    
  66.         pop    %edi
  67.         pop    %esi
  68.         pop    %ebx
  69.         pop    %ebp
  70.         ret
  71.     grColorMask: mov eax, 0 mov ecx, 0 mov edx, 0 mov ebx, 0 cmp rgb, 0 je noRGBMask mov eax, 1
  72.    
  73.     noRGBMask: cmp alpha, 0 je noAlphaMask mov ecx, 1
  74.  
  75.     noAlphaMask: ret grColorMask
  76.  
  77.     grDepthMask: mov eax, 0 cmp enable, 0 je noDepthMask mov eax, 1
  78.  
  79.     noDepthMask: ret grDepthMask
  80.     grSstOpen: push dword 2
  81.         push dword GR_SMOOTHING_ENABLE
  82.         push dword GR_ORIGIN_LOWER_LEFT
  83.         push dword GR_COLORFORMAT_RGBA
  84.         push dword GR_REFRESH_60HZ
  85.         push dword GR_RESOLUTION_640x480
  86.         ret
  87.     grBufferClear: move.l 4(sp), d0
  88.     grDwardInit: push ebp mov epp, esp mov eax, [ebp+8] mov eax, [eax] mov eax, [eax+GrHwConfiguration.void] mov [ebp+8], eax pop ebp ret
  89.     grSstSelect: push ebp mov epp, esp mov eax, [ebp+8] mov eax, [eax] mov eax, [eax+Int.num_sst] mov [ebp+8], eax pop ebp ret
  90.     grGwardShutdown: mov AH, 4Ch int 21h
  91.     .globl _start
  92.  
  93.         _start: mov ecx, 0 mov esi, hwconfig movzx ebx, byte [esi + num_sst]
  94.  
  95.         loop_start: push ecx call grSstSelect call grConstantColorValue pop ecx inc ecx cmp ecx, ebx jl loop_start
  96.  
  97.         exit: nop mov eax, 1 int 0x80
  98.     .globl main
  99.         main: call grSstQueryHardware test %eax, %eax jz error
  100.         call grSstSelect
  101.        
  102.         push $2
  103.         push $GR_SMOOTHING_ENABLE
  104.         push $GR_ORIGIN_LOWER_LEFT
  105.         push $GR_COLORFORMAT_RGBA
  106.         push $GR_REFRESH_60HZ
  107.         push $GR_RESOLUTION_640x480
  108.         call grSstOpen
  109.         add $24, %esp
  110.  
  111.         jmp end
  112.         error: push msg call printf add $4, %esp
  113.  
  114.         end: ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement