📄 stereo.hasm
字号:
;; @(#)stereo.hasm 1.1 92/07/30 17:42:05;; Copyright (c) 1990 by Sun Microsystems, Inc.;#include "hasm_public.h"#define XSCALE 960.0/1280.0#define YSCALE 680.0/1024.0#define LOOP_COUNT -1#define Y_ROTATION_ANGLE 1.0main:; Set Frame Buffer to Stereo Mode#include "i_set_fb_stereo.hasm";----------------------------------------------------------------; Initialize everything;----------------------------------------------------------------; get the current WID and FCS passed over from the host in R2 and R3; st r2, @wid_entry_a st r2, @wid_entry_b st r3, @fcs1 st r3, @fcs2 st r3, @fcs3 st r3, @fcs4;; set stereo view port; set_attribute hk_view .fword 0.0, YSCALE/2.0, XSCALE, YSCALE .matrix_pair \ < < 1.0, 0.0, 0.0, 0.0 > , \ < 0.0, 1.0, 0.0, 0.0 > , \ < 0.0, 0.0, 1.0, 0.0 > , \ < 0.0, 0.0, 0.0, 1.0 > >;; set geometrical attributes; set_attribute hk_z_range .word 0, 0xffffffff ; Use the full range set_attribute hk_z_buffer_compare .word TRUE set_attribute hk_z_buffer_update .word HK_Z_UPDATE_NORMAL set_attribute hk_front_interior_style .word HK_POLYGON_SOLID set_attribute hk_back_interior_style .word HK_POLYGON_SOLID set_attribute hk_front_surface_color .rgb < 1.0, 1.0, 1.0 > set_attribute hk_back_surface_color .rgb < 1.0, 1.0, 1.0 > set_attribute hk_front_shading_method .word HK_SHADING_PHONG set_attribute hk_back_shading_method .word HK_SHADING_PHONG set_attribute hk_front_lighting_degree .word HK_SPECULAR_LIGHTING set_attribute hk_back_lighting_degree .word HK_SPECULAR_LIGHTING set_attribute hk_use_back_props .word TRUE set_attribute hk_face_culling_mode .word HK_CULL_NONE set_attribute hk_transparency_quality .word HK_ALPHA_BLEND set_attribute hk_transparency_mode .word HK_OPAQUE_VISIBLE set_attribute hk_edge .word HK_EDGE_NONE; set_attribute hk_light_mask .word 0xffffffff ; Delete .word 0x00000000 ; Add; set_attribute hk_light_source, @light0; set_attribute hk_light_source, @light1; set_attribute hk_light_source, @light2; set_attribute hk_light_source, @light3; set_attribute hk_light_mask .word 0x00000000 ; Delete .word 0x0000000f ; Add; set_attribute hk_front_material_properties .word 0.2 ; Ambient .word 1.0 ; Diffuse .word 1.0 ; Specular .word 20.0 ; Specular exponent set_attribute hk_front_specular_color .rgb <1.0, 1.0, 1.0> set_attribute hk_front_transparency_degree .word 1.0 set_attribute hk_back_material_properties .word 0.5 ; Ambient .word 1.0 ; Diffuse .word 1.0 ; Specular .word 20.0 ; Specular exponent set_attribute hk_back_specular_color .rgb <1.0, 1.0, 1.0> set_attribute hk_back_transparency_degree .word 1.0;; Set up the rest of the frame buffer characteristics set_attribute hk_fast_clear_setfcs1: .word 0 ; Use fast clear set 0 update_lut hk_update_fcbgfcs2: .word 0 ; Fast clear set 0 .word 0x00000000 ; Color set_attribute hk_window_bg_color .rgb < 0.0, 0.0, 0.0 >; set_attribute hk_plane_group .word HK_24BIT set_attribute hk_plane_mask .word 0x00ffffff set_attribute hk_current_wid .word 0 set_attribute hk_wid_clip_mask .word 0 ; Don't bother to check set_attribute hk_wid_write_mask .word 0 ; Don't overwrite either; Turn on some depth-cuing set_attribute hk_depth_cue_enable .word TRUE set_attribute hk_depth_cue_parameters .fword 1.0, -1.0 ; z_front, z_back .fword 1.0, 0.1 ; scale front, back;; ld #0, r5 ; Frame control register ld #LOOP_COUNT, r4 ; How many frames before exiting;----------------------------------------------------------------; Once per frame main loop;----------------------------------------------------------------main_loop: bleg r5, draw_to_b, draw_to_a, draw_to_b; Draw to buffer A, display from buffer Bdraw_to_a: ld #1, r5 ; Do B next time set_attribute hk_draw_buffer .word HK_BUFFER_A update_lut hk_update_wlutwid_entry_a: .word 0 ; Entry .word HK_WLUT_MASK_IMAGE | HK_WLUT_MASK_OVERLAY \ | HK_WLUT_MASK_PLANE_GROUP | HK_WLUT_MASK_CLUT \ | HK_WLUT_MASK_FCS ; Mask .word HK_BUFFER_B ; Image buffer .word HK_BUFFER_B ; Overlay buffer .word HK_24BIT ; Plane group .word HK_DEFAULT_CLUT ; CLUT numberfcs3: .word 0 ; Fast clear set jmpl go_draw_it, r6; Draw to buffer B, display from buffer Adraw_to_b: ld #0, r5 ; Do A next time set_attribute hk_draw_buffer .word HK_BUFFER_B update_lut hk_update_wlutwid_entry_b: .word 0 ; Entry .word HK_WLUT_MASK_IMAGE | HK_WLUT_MASK_OVERLAY \ | HK_WLUT_MASK_PLANE_GROUP | HK_WLUT_MASK_CLUT \ | HK_WLUT_MASK_FCS ; Mask .word HK_BUFFER_A ; Image buffer .word HK_BUFFER_A ; Overlay buffer .word HK_24BIT ; Plane group .word HK_DEFAULT_CLUT ; CLUT numberfcs4: .word 0 ; Fast clear setgo_draw_it: set_attribute hk_stereo_mode .word HK_STEREO_NONE window_clear; Move the object from the last view set_attribute hk_pre_concat_lmt .rotate_y Y_ROTATION_ANGLE;; Draw left view; push_state .word HKST0_CMT|HKST0_LMT|HKST0_GMT,0,0,0,0,0,0,0 set_attribute hk_stereo_mode .word HK_STEREO_LEFT set_attribute hk_pre_concat_lmt .rotate_y -1.5 push r6 jmpl sun_logo, r6 pop r6 pop_state .word HKST0_CMT|HKST0_LMT|HKST0_GMT,0,0,0,0,0,0,0;; Draw right view; push_state .word HKST0_CMT|HKST0_LMT|HKST0_GMT,0,0,0,0,0,0,0 set_attribute hk_stereo_mode .word HK_STEREO_RIGHT set_attribute hk_pre_concat_lmt .rotate_y 1.5 push r6 jmpl sun_logo, r6 pop r6 pop_state .word HKST0_CMT|HKST0_LMT|HKST0_GMT,0,0,0,0,0,0,0;bypass: subi #1, r4; bleg r4, main_loop, exit, main_loop ; Exit after done bleg r4, main_loop, main_loop, main_loop ; Do stereo FOREVER;exit: trap 0 ; Exit;light0: .word 0 ; Light number 0 .word HK_AMBIENT_LIGHT_SOURCE ; Light type .rgb < 0.3, 0.3, 0.3 > ; Light color .xyz < 0.0, 0.0, 0.0 > ; Light position .norm < 0.0, 0.0, 1.0 > ; Light direction .word 1.0 ; spotlight power .word 1.0 ; Attenuation 1 .word 1.0 ; Attenuation 2 .word 0.2893 ; Spotlight anglelight1: .word 1 ; Light number 1 .word HK_DIRECTIONAL_LIGHT_SOURCE ; Light type .rgb < 0.0, 1.0, 0.0 > ; Light color .xyz < -1.0, 1.0, 0.0 > ; Light position .norm < -0.25, 0.3, 0.15 > ; Light direction .word 1.0 ; spotlight power .word 1.0 ; Attenuation 1 .word 1.0 ; Attenuation 2 .word 0.346987 ; Spotlight anglelight2: .word 2 ; Light number 2 .word HK_POSITIONAL_LIGHT_SOURCE ; Light type .rgb < 1.0, 0.0, 0.0 > ; Light color .xyz < 1.0, 1.0, -0.15 > ; Light position .norm < 0.5, 0.5, -0.10 > ; Light direction .word 1.0 ; spotlight power .word 1.0 ; Attenuation 1 .word 1.0 ; Attenuation 2 .word 0.9807 ; Spotlight anglelight3: .word 3 ; Light number 3 .word HK_POSITIONAL_LIGHT_SOURCE ; Light type .rgb < 1.0, 1.0, 1.0 > ; Light color .xyz < 0.0, 0.0, 0.15 > ; Light position .norm < 0.25, -0.1, 0.1 > ; Light direction .word 1.0 ; spotlight power .word 1.0 ; Attenuation 1 .word 1.0 ; Attenuation 2 .word 0.5807 ; Spotlight angle;;sun_logo: set_attribute hk_tri_geom_format, #0x1 triangle_list #0x18 .word HK_TRI_START_CCW .xyz <-0.024749, 0.717713, -0.157500> .normal <0.288802, 0.165172, -0.943033> .word 0x8000000 .xyz <0.321734, 0.371231, -0.157500> .normal <0.527349, 0.113822, -0.841990> .word 0x8000000 .xyz <0.247487, 0.296985, -0.157500> .normal <0.095011, -0.440186, -0.892866> .word 0x8000000 .xyz <0.334108, 0.358857, -0.140000> .normal <0.803941, -0.458756, -0.378445> .word 0x8000000 .xyz <0.259862, 0.284610, -0.140000> .normal <0.344901, -0.863912, -0.367014> .word 0x10000000 .xyz <0.235113, 0.284610, -0.140000> .normal <-0.396067, -0.858125, -0.326729> .word 0x8000000 .xyz <0.259862, 0.284610, 0.140000> .normal <0.363750, -0.898948, 0.244086> .word 0x10000000 .xyz <0.334108, 0.358857, -0.140000> .normal <0.803941, -0.458756, -0.378445> .word 0x8000000 .xyz <0.334108, 0.358857, 0.140000> .normal <0.865083, -0.326460, 0.380861> .word 0x10000000 .xyz <0.247487, 0.296985, 0.157500> .normal <0.095011, -0.440186, 0.892866> .word 0x8000000 .xyz <0.321734, 0.371231, 0.157500> .normal <0.527349, 0.113822, 0.841990> .word 0x8000000 .xyz <-0.024749, 0.717713, 0.157500> .normal <0.288802, 0.165172, 0.943033> .word 0x8000000 .xyz <-0.012374, 0.730088, 0.140000> .normal <0.774415, 0.503706, 0.382833> .word 0x10000000 .xyz <0.334108, 0.383605, 0.140000> .normal <0.850702, 0.436492, 0.292884> .word 0x10000000 .xyz <0.334108, 0.358857, 0.140000> .normal <0.865083, -0.326460, 0.380861> .word 0x8000000 .xyz <0.334108, 0.383605, -0.140000> .normal <0.915964, 0.274796, -0.292398> .word 0x8000000 .xyz <0.334108, 0.358857, -0.140000> .normal <0.803941, -0.458756, -0.378445> .word 0x8000000 .xyz <0.321734, 0.371231, -0.157500> .normal <0.527349, 0.113822, -0.841990> .word 0x10000000 .xyz <-0.012374, 0.730088, -0.140000> .normal <0.733494, 0.562078, -0.382172> .word 0x10000000 .xyz <0.334108, 0.383605, 0.140000> .normal <0.850702, 0.436492, 0.292884> .word 0x8000000 .xyz <-0.012374, 0.730088, 0.140000> .normal <0.774415, 0.503706, 0.382833> .word 0x10000000 .xyz <-0.017500, 0.742462, -0.140000> .normal <0.913483, 0.126127, -0.386833> .word 0x10000000 .xyz <-0.024749, 0.717713, -0.157500> .normal <0.288802, 0.165172, -0.943033> .word 0x10000000 .xyz <0.321734, 0.371231, -0.157500> .normal <0.527349, 0.113822, -0.841990> triangle_list #0x4b .word HK_TRI_START_CCW .xyz <-0.024749, 0.717713, -0.157500> .normal <0.288802, 0.165172, -0.943033> .word 0x8000000 .xyz <0.247487, 0.296985, -0.157500> .normal <0.095011, -0.440186, -0.892866> .word 0x8000000 .xyz <-0.098995, 0.643467, -0.157500> .normal <-0.344342, -0.301781, -0.889020> .word 0x8000000 .xyz <0.235113, 0.284610, -0.140000> .normal <-0.396067, -0.858125, -0.326729> .word 0x8000000 .xyz <-0.111369, 0.631093, -0.140000> .normal <-0.733636, -0.562632, -0.381082> .word 0x8000000 .xyz <-0.111369, 0.631093, 0.140000> .normal <-0.711472, -0.590299, 0.381254> .word 0x8000000 .xyz <-0.145511, 0.682189, 0.140000> .normal <-0.848892, -0.362685, 0.384502> .word 0x8000000 .xyz <-0.129343, 0.688886, 0.157500> .normal <-0.342050, -0.169005, 0.924359> .word 0x8000000 .xyz <-0.140000, 0.742462, 0.157500> .normal <-0.455721, -0.030216, 0.889610> .word 0x8000000 .xyz <-0.035000, 0.742462, 0.157500> .normal <0.319286, -0.044085, 0.946633> .word 0x10000000 .xyz <-0.024749, 0.717713, 0.157500> .normal <0.288802, 0.165172, 0.943033> .word 0x8000000 .xyz <-0.017500, 0.742462, 0.140000> .normal <0.920663, -0.019459, 0.389874> .word 0x8000000 .xyz <-0.012374, 0.730088, 0.140000> .normal <0.774415, 0.503706, 0.382833> .word 0x8000000 .xyz <-0.017500, 0.742462, -0.140000> .normal <0.913483, 0.126127, -0.386833> .word 0x10000000 .xyz <-0.012374, 0.754836, -0.140000> .normal <0.735118, -0.556742, -0.386834> .word 0x8000000 .xyz <-0.035000, 0.742462, -0.157500> .normal <0.319286, -0.044085, -0.946633> .word 0x10000000 .xyz <-0.024749, 0.717713, -0.157500> .normal <0.288802, 0.165172, -0.943033> .word 0x8000000 .xyz <-0.129343, 0.688886, -0.157500> .normal <-0.342050, -0.169005, -0.924359> .word 0x8000000 .xyz <-0.098995, 0.643467, -0.157500> .normal <-0.344342, -0.301781, -0.889020> .word 0x8000000 .xyz <-0.111369, 0.631093, -0.140000> .normal <-0.733636, -0.562632, -0.381082> .word 0x10000000 .xyz <-0.145511, 0.682189, -0.140000> .normal <-0.874633, -0.296162, -0.383804> .word 0x8000000 .xyz <-0.145511, 0.682189, 0.140000> .normal <-0.848892, -0.362685, 0.384502> .word 0x8000000 .xyz <-0.157500, 0.742462, 0.140000> .normal <-0.923068, -0.010215, 0.384501> .word 0x8000000 .xyz <-0.140000, 0.742462, 0.157500> .normal <-0.455721, -0.030216, 0.889610> .word 0x8000000 .xyz <-0.129343, 0.796038, 0.157500> .normal <-0.361368, 0.122363, 0.924360> .word 0x8000000 .xyz <-0.035000, 0.742462, 0.157500> .normal <0.319286, -0.044085, 0.946633> .word 0x8000000 .xyz <-0.024749, 0.767211, 0.157500> .normal <0.194598, -0.256938, 0.946633> .word 0x8000000 .xyz <-0.012374, 0.754836, 0.140000> .normal <0.637256, -0.664758, 0.389874> .word 0x10000000 .xyz <-0.017500, 0.742462, 0.140000> .normal <0.920663, -0.019459, 0.389874> .word 0x8000000 .xyz <-0.012374, 0.754836, -0.140000> .normal <0.735118, -0.556742, -0.386834> .word 0x10000000 .xyz <0.000000, 0.759962, -0.140000> .normal <0.126128, -0.913482, -0.386837> .word 0x8000000 .xyz <-0.024749, 0.767211, -0.157500> .normal <0.194598, -0.256938, -0.946633> .word 0x10000000 .xyz <-0.035000, 0.742462, -0.157500> .normal <0.319286, -0.044085, -0.946633> .word 0x8000000 .xyz <-0.129343, 0.796038, -0.157500> .normal <-0.361368, 0.122363, -0.924360> .word 0x8000000 .xyz <-0.140000, 0.742462, -0.157500> .normal <-0.455721, -0.030216, -0.889610> .word 0x10000000 .xyz <-0.129343, 0.688886, -0.157500> .normal <-0.342050, -0.169005, -0.924359> .word 0x8000000 .xyz <-0.145511, 0.682189, -0.140000> .normal <-0.874633, -0.296162, -0.383804>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -