; HSPDX es_excopy sample 2 ; ウインドウモードをフルスクリーンモードのように見せかける ; Window ID=2 を描画対象にしている ; ; 2023/11/29, use HSP 3.7 beta 7, Windows10 x64 22H2 #include "hspdx.as" #packopt name "01_hspdx_es_excopy2" ; file name #packopt type 0 ; generate ".exe" #define TEXFILE "tex.bmp" #pack TEXFILE #define KB_ESC $00080 ; 以下の行をコメントアウトするとウインドウモードになる #define FULLSCR ; hspdx.dllが存在するか確認 exist "hspdx.dll" if strsize < 0 { dialog "Not found hspdx.dll" end } #ifdef FULLSCR ; get desktop size wdw_w = ginfo_dispx wdw_h = ginfo_dispy ; scmode = 0 ; set fullscreen scmode = 1 ; set window mode use_d3d = 1 #else ; wdw_w = 512 ; wdw_h = 288 wdw_w = 1600 wdw_h = 900 scmode = 1 ; set window mode use_d3d = 1 #endif ; 最初に作られる Window ID=0 を非表示にする gsel 0, -1 actid = 2 ; Window ID=2 を表示ウインドウにする #ifdef FULLSCR ; フルスクリーン相当。枠無しウインドウを作成 bgscr actid, wdw_w, wdw_h, 0, 0, 0, wdw_w, wdw_h #else ; ウインドウモード。通常のウインドウを作成 screen actid, wdw_w, wdw_h, 0, 20, 20, wdw_w, wdw_h #endif es_ini ; initialize HSPDX onexit *job_end es_screen wdw_w, wdw_h, 32, 0, scmode, use_d3d if stat == 1 { dialog "Error : DirectX initialization failed." end } if stat == 2 { dialog "Error : Screen initialization failed." end } *start ; load texture image file buffer 5, 256, 256 picload TEXFILE texid = 0 es_buffer texid, 0 ; copy buffer to VRAM if stat { es_bye wait 100 dialog "Error : Not enough VRAM." end } gsel actid, 1 ; Activate window es_cls ; screen clear es_sync (1000/60), 1 ; wait wait 100 font "Tahoma", 16, 1 tt = 0 k = 0 x = double(wdw_w / 2) dx = double(wdw_w) / double(60 * 3) now_fps = 0 *mainloop ; get fps es_getfps now_fps ; title strf("%d/50 FPS", now_fps) stick k, 0 ; chekc keyboard if k & KB_ESC : goto *job_end ; ESC key to exit x += dx if x <= 0.0 or (x + 16.0) >= wdw_w { ; flip direction dx *= -1 } ; draw start gsel actid es_cls $40, $80, $c0 ; screen clear ; draw image gmode gmode_rgb0, 16, 16 pos int(x), 10 es_copy texid, 0, 0, 16, 16 ; es_excopy texid, 0, 0, 16, 16, 64, 64 repeat 8 ; draw image px = 0 py = 40 + (16 + 2) * cnt sx = 0 ; source x, y sy = 0 sw = 16 ; source width, height sh = 16 dw = 14 + cnt ; dest width, height dh = 16 gmode gmode_rgb0, sw, sh objsize dw, dh pos px, py ; es_zoom texid, sx, sy, sw, sh, dw, dh es_excopy texid, sx, sy, sw, sh, dw, dh ; box fill px = px + dw + 2 gmode 0, sw, sh color 32, 32, 32 pos px, py es_boxf px, py, px + dw - 1, py + dh - 1 loop pos (wdw_w / 2) - (16 * 4), 0 color 255, 255, 255 es_fmes strf("%d/60FPS", now_fps) es_sync (1000/60), 1 ; draw and wait tt = stat await 1 goto *mainloop *job_end es_bye end