2016-03-04 76 views
0

我目前在easy68k中創建了一個簡單的空間風格的資源管理遊戲。如何使用easy68k緩慢輸出文本到控制檯

我的遊戲的一部分由一個簡單的循環組成,這個循環表示玩家隊伍離開主基地到他們到達任務目的地的時間點。環路由行駛距離和船舶燃料控制。所以如果燃料用完了,我會添加一個功能,讓玩家知道他們沒有到達目的地,他們已經失去了船隻。

在所有這些情況之間,我有一個從1-100產生的隨機數,這取決於產生的數字,可能發生某些事件,例如玩家會找到一些救助人員,船員,棄船,海盜等等。當一個發生這些事件時,我想輸出一條消息給控制檯屏幕讓玩家知道。

我的問題是,當循環運行時,如果發生任何事件,它們都會在不到一秒的時間內輸出到屏幕上,並且玩家最終錯過了大部分事件。

我想知道,有沒有辦法延遲輸出,以便寫作出現在玩家可以輕鬆遵循的速度?

任何幫助將不勝感激。

如果它在這裏有幫助是我的循環,我沒有完全實現所有機制,但循環本身工作正常。

 *------------------------------------------------------- 
     *---------------Update Mission Progress----------------- 
     * Move to mission location, random events will occur 
     *------------------------------------------------------- 
update: 
bsr  endl   print a CR and LF 
bsr  decorate  decorate with dots using a loop 

move.w $4000, D7  move distance value into D7 
move.w $4020, D6  move fuel value into D6 

lea  update_msg,A1 Display update message 
move.b #14,D0 
trap #15 

update_loop: 

move.b #8,d0   Get time 1/100th seconds since midnight 
trap #15 
and.l #$5FFFFF,D1  prevent overflow in divu 
divu #100,D1   time count/100 
swap D1    swap upper and lower words of D1 to put remainder in low word 
addq.w #1,D1   d1.w contains number from 1 to 100 
move D1,D2   d2 = d1 

bsr  check_events check to see if any of the events will occur 

sub.b #fuel_cost, D6 reduce ships fuel by one 
CMP  #0, D6   if the ships fuel reaches 0 then go to out of fuel routine 
BEQ  out_of_fuel  

sub.b #1, D7   reduce mission distance by 1    
CMP  #0, D7   when it reaches 0 go to the continue subroutine    
BNE  update_loop  otherwise go back to the top of the loop 

BRA  continue_loop 

continue_loop: 
*Used to leave the update loop 
lea  continue_msg,A1 
move.b #14,D0 
trap #15 

move.b #5,D0   wait for input so the player can read the event messages 
trap #15 

CMP  $94, D1 
BNE  continue_loop 


move.w D6, $4020  store the new value for ship fuel 

bsr  decorate       
rts 

check_events:  
*Check to make sure the random value is within the specific range for each event 
CMP  #95, D2 
BGE  check_found_salvage 

CMP  #75, D2 
BGE  check_hit_mine 

CMP  #55, D2 
BGE  check_pirate_attack 

CMP  #35, D2 
BGE  check_found_ship 

CMP  #15, D2 
BGE  check_found_crew 

rts 
*Further checks to make sure the random value is within the specific ranges 
check_found_salvage: 

CMP  #97, D2     
BLE  collect_salvage    
rts         

check_hit_mine: 

CMP  #77, D2      
BLE  hit_mine    
rts     

check_pirate_attack: 

CMP  #57, D2      
BLE  initiate_attack    
rts     

check_found_ship: 

CMP  #37, D2 
BLE  check_collect_ship 
RTS 

check_found_crew: 

CMP  #17, D2 
BLE  collect_crew 
rts 
*Run each event, outputting a message to the screen if an event occurs 
collect_salvage: 

lea  found_salvage_msg,A1 
move.b #14,D0 
trap #15 

rts         

hit_mine: 

lea  hit_mine_msg,A1 
move.b #14,D0 
trap #15 

rts 

initiate_attack:  

lea  initiate_attack_msg,A1 
move.b #14,D0 
trap #15 

rts 

check_collect_ship:  

lea  found_ship_msg ,A1 
move.b #14,D0 
trap #15 

rts 

collect_crew:  

lea  found_crew_msg,A1 
move.b #14,D0 
trap #15 

rts 
*Not fully implemented out of fuel mechanic yet 
out_of_fuel: 
rts 
+0

將事件放入隊列中,並顯示適當的延遲? – Jester

+0

幾個星期前我纔開始裝配,所以我不確定我會怎麼做呢? –

+0

不確定哪個部分導致您的問題?你能用C做嗎? – Jester

回答

1

按照Easy68k論壇有陷阱,只是等待指定的時間量:

move.l #100,D1  ; delay in 1/100th of seconds 
moveq #23,D0 
trap  #15 

你可以只使用這個陷阱等待打印位在事件之後?

+0

這實際上是完美的,所以謝謝你,但現在我已經能夠減慢循環,我注意到我的事件只出現在屏幕上,當我調試我的程序。如果我試圖通常運行程序,它會顯示更新消息,然後在進入下一個循環之前提示用戶輸入。這可能是因爲程序在不調試時運行速度如此之快以至於陷阱8函數生成的數字每次都完全相同? –